diff --git a/src/ifcsverchok/__init__.py b/src/ifcsverchok/__init__.py index 05a8d4ce32..697e97ba0e 100644 --- a/src/ifcsverchok/__init__.py +++ b/src/ifcsverchok/__init__.py @@ -26,6 +26,9 @@ def nodes_index(): ("ifc.read_file", "SvIfcReadFile"), ("ifc.write_file", "SvIfcWriteFile"), ("ifc.create_entity", "SvIfcCreateEntity"), + ("ifc.by_id", "SvIfcById"), + ("ifc.by_guid", "SvIfcByGuid"), + ("ifc.by_type", "SvIfcByType"), ])] def make_node_list(): diff --git a/src/ifcsverchok/nodes/ifc/by_guid.py b/src/ifcsverchok/nodes/ifc/by_guid.py new file mode 100644 index 0000000000..4ded1955ca --- /dev/null +++ b/src/ifcsverchok/nodes/ifc/by_guid.py @@ -0,0 +1,31 @@ +import bpy +import ifcopenshell +import ifcsverchok.helper +from bpy.props import StringProperty +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import updateNode + + +class SvIfcByGuid(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore): + bl_idname = 'SvIfcByGuid' + bl_label = 'IFC By Guid' + file: StringProperty(name='file', update=updateNode) + guid: StringProperty(name='guid', update=updateNode) + + def sv_init(self, context): + self.inputs.new('SvStringsSocket', 'file').prop_name = 'file' + self.inputs.new('SvStringsSocket', 'guid').prop_name = 'guid' + self.outputs.new('SvStringsSocket', 'entity') + + def process(self): + self.sv_input_names = ['file', 'guid'] + super().process() + + def process_ifc(self, file, guid): + self.outputs['entity'].sv_set([[file.by_guid(guid)]]) + +def register(): + bpy.utils.register_class(SvIfcByGuid) + +def unregister(): + bpy.utils.unregister_class(SvIfcByGuid) diff --git a/src/ifcsverchok/nodes/ifc/by_id.py b/src/ifcsverchok/nodes/ifc/by_id.py new file mode 100644 index 0000000000..e683de3b63 --- /dev/null +++ b/src/ifcsverchok/nodes/ifc/by_id.py @@ -0,0 +1,31 @@ +import bpy +import ifcopenshell +import ifcsverchok.helper +from bpy.props import StringProperty +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import updateNode + + +class SvIfcById(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore): + bl_idname = 'SvIfcById' + bl_label = 'IFC By Id' + file: StringProperty(name='file', update=updateNode) + id: StringProperty(name='id', update=updateNode) + + def sv_init(self, context): + self.inputs.new('SvStringsSocket', 'file').prop_name = 'file' + self.inputs.new('SvStringsSocket', 'id').prop_name = 'id' + self.outputs.new('SvStringsSocket', 'entity') + + def process(self): + self.sv_input_names = ['file', 'id'] + super().process() + + def process_ifc(self, file, id): + self.outputs['entity'].sv_set([[file.by_id(int(id))]]) + +def register(): + bpy.utils.register_class(SvIfcById) + +def unregister(): + bpy.utils.unregister_class(SvIfcById) diff --git a/src/ifcsverchok/nodes/ifc/by_type.py b/src/ifcsverchok/nodes/ifc/by_type.py new file mode 100644 index 0000000000..acd1a6b262 --- /dev/null +++ b/src/ifcsverchok/nodes/ifc/by_type.py @@ -0,0 +1,31 @@ +import bpy +import ifcopenshell +import ifcsverchok.helper +from bpy.props import StringProperty +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import updateNode + + +class SvIfcByType(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore): + bl_idname = 'SvIfcByType' + bl_label = 'IFC By Type' + file: StringProperty(name='file', update=updateNode) + type: StringProperty(name='type', update=updateNode) + + def sv_init(self, context): + self.inputs.new('SvStringsSocket', 'file').prop_name = 'file' + self.inputs.new('SvStringsSocket', 'type').prop_name = 'type' + self.outputs.new('SvStringsSocket', 'entity') + + def process(self): + self.sv_input_names = ['file', 'type'] + super().process() + + def process_ifc(self, file, type): + self.outputs['entity'].sv_set([file.by_type(type)]) + +def register(): + bpy.utils.register_class(SvIfcByType) + +def unregister(): + bpy.utils.unregister_class(SvIfcByType)