diff --git a/src/ifcsverchok/__init__.py b/src/ifcsverchok/__init__.py index 524190e857..4ac86a8f24 100644 --- a/src/ifcsverchok/__init__.py +++ b/src/ifcsverchok/__init__.py @@ -30,6 +30,7 @@ def nodes_index(): ("ifc.by_guid", "SvIfcByGuid"), ("ifc.by_type", "SvIfcByType"), ("ifc.by_query", "SvIfcByQuery"), + ("ifc.select_blender_objects", "SvIfcSelectBlenderObjects"), ])] def make_node_list(): diff --git a/src/ifcsverchok/nodes/ifc/select_blender_objects.py b/src/ifcsverchok/nodes/ifc/select_blender_objects.py new file mode 100644 index 0000000000..abac004cbf --- /dev/null +++ b/src/ifcsverchok/nodes/ifc/select_blender_objects.py @@ -0,0 +1,37 @@ +import bpy +import ifcopenshell +import ifcopenshell.util.selector +import ifcsverchok.helper +from bpy.props import StringProperty +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import updateNode + + +class SvIfcSelectBlenderObjects(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore): + bl_idname = 'SvIfcSelectBlenderObjects' + bl_label = 'IFC Select Blender Objects' + file: StringProperty(name='file', update=updateNode) + query: StringProperty(name='query', update=updateNode) + + def sv_init(self, context): + self.inputs.new('SvStringsSocket', 'entities').prop_name = 'entities' + + def process(self): + self.sv_input_names = ['entities'] + self.guids = [] + super().process() + for obj in bpy.context.visible_objects: + index = obj.BIMObjectProperties.attributes.find('GlobalId') + if index != -1 \ + and obj.BIMObjectProperties.attributes[index].string_value in self.guids: + obj.select_set(True) + + def process_ifc(self, entities): + self.guids.append(entities.GlobalId) + + +def register(): + bpy.utils.register_class(SvIfcSelectBlenderObjects) + +def unregister(): + bpy.utils.unregister_class(SvIfcSelectBlenderObjects)