From 84509b7cc2c3d4af4412e52f5592bd3be62b296c Mon Sep 17 00:00:00 2001 From: htlcnn Date: Mon, 9 Nov 2020 16:21:20 +0700 Subject: [PATCH] add IfcClass selector for Ifc By Type node --- src/ifcsverchok/nodes/ifc/by_type.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ifcsverchok/nodes/ifc/by_type.py b/src/ifcsverchok/nodes/ifc/by_type.py index 26c570e0f0..92b63ff085 100644 --- a/src/ifcsverchok/nodes/ifc/by_type.py +++ b/src/ifcsverchok/nodes/ifc/by_type.py @@ -5,26 +5,34 @@ from bpy.props import StringProperty, EnumProperty from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import updateNode from blenderbim.bim import schema +from blenderbim.bim.prop import getIfcClasses, getIfcProducts, refreshClasses, refreshPredefinedTypes class SvIfcByType(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.SvIfcCore): bl_idname = "SvIfcByType" bl_label = "IFC By Type" - ifc_element_types = [(t, t, t) for t in schema.IfcSchema().IfcElementType.keys()] file: StringProperty(name="file", update=updateNode) - type: EnumProperty(name="type", items=ifc_element_types) + ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses) + ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes) + ifc_element_types = [(t, t, t) for t in schema.IfcSchema().IfcElementType.keys()] + custom_ifc_class: StringProperty(name="Custom Ifc Class", update=updateNode) def sv_init(self, context): self.inputs.new("SvStringsSocket", "file").prop_name = "file" - self.inputs.new("SvStringsSocket", "type").prop_name = "type" + self.inputs.new("SvStringsSocket", "ifc_product").prop_name = "ifc_product" + self.inputs.new("SvStringsSocket", "ifc_class").prop_name = "ifc_class" + self.inputs.new("SvStringsSocket", "custom_ifc_class").prop_name = "custom_ifc_class" self.outputs.new("SvStringsSocket", "entity") def process(self): - self.sv_input_names = ["file", "type"] + self.sv_input_names = ["file", "ifc_product", "ifc_class", "custom_ifc_class"] super().process() - def process_ifc(self, file, type): - self.outputs["entity"].sv_set([file.by_type(type)]) + def process_ifc(self, file, ifc_product, ifc_class, custom_ifc_class): + if not custom_ifc_class: + self.outputs["entity"].sv_set([file.by_type(ifc_class)]) + else: + self.outputs["entity"].sv_set([file.by_type(custom_ifc_class)]) def register():