From b044ddfaa2ef0aa77bc6386aa5a8ef609d8dfdeb Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 31 Jul 2023 23:31:57 +1000 Subject: [PATCH] Flow segments are now created at a specific RL above the active storey in the BIM Tool --- .../blenderbim/bim/module/model/product.py | 22 ++++++++++++------- .../blenderbim/bim/module/model/prop.py | 2 +- .../blenderbim/bim/module/model/workspace.py | 11 +++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index 92a465446e..61f343c96c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -131,19 +131,17 @@ class AddConstrTypeInstance(bpy.types.Operator): if self.from_invoke: props.relating_type_id = str(self.relating_type_id) - self.file = IfcStore.get_file() - relating_type = self.file.by_id(int(relating_type_id)) + relating_type = tool.Ifc.get().by_id(int(relating_type_id)) ifc_class = relating_type.is_a() - instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, self.file.schema)[0] + instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, tool.Ifc.get().schema)[0] material = ifcopenshell.util.element.get_material(relating_type) if material and material.is_a("IfcMaterialProfileSet"): if obj := profile.DumbProfileGenerator(relating_type).generate(): - if not relating_type.is_a("IfcFlowSegmentType"): - return {"FINISHED"} - mep.MepGenerator(relating_type).setup_ports(obj) + if relating_type.is_a("IfcFlowSegmentType"): + self.set_flow_segment_rl(obj) + mep.MepGenerator(relating_type).setup_ports(obj) return {"FINISHED"} - elif material and material.is_a("IfcMaterialLayerSet"): if self.generate_layered_element(ifc_class, relating_type): tool.Blender.select_and_activate_single_object(context, context.selected_objects[-1]) @@ -189,6 +187,7 @@ class AddConstrTypeInstance(bpy.types.Operator): blenderbim.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type) # Update required as core.type.assign_type may change obj.data + # TODO: This is inefficient. It literally creates a mesh, then potentially removes it. context.view_layer.update() if ( @@ -230,7 +229,7 @@ class AddConstrTypeInstance(bpy.types.Operator): # TODO For now we are hardcoding windows and doors as a prototype bpy.ops.bim.add_filled_opening(voided_obj=building_obj.name, filling_obj=obj.name) else: - if collection_obj and collection_obj.BIMObjectProperties.ifc_definition_id: + if collection_obj and tool.Ifc.get_entity(collection_obj): obj.location[2] = collection_obj.location[2] - min([v[2] for v in obj.bound_box]) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) @@ -250,6 +249,13 @@ class AddConstrTypeInstance(bpy.types.Operator): tool.Blender.select_and_activate_single_object(context, obj) return {"FINISHED"} + def set_flow_segment_rl(self, obj): + collection = bpy.context.view_layer.active_layer_collection.collection + collection_obj = collection.BIMCollectionProperties.obj + + if collection_obj and tool.Ifc.get_entity(collection_obj): + obj.location[2] = collection_obj.location[2] + bpy.context.scene.BIMModelProperties.rl2 + @staticmethod def generate_layered_element(ifc_class, relating_type): layer_set_direction = None diff --git a/src/blenderbim/blenderbim/bim/module/model/prop.py b/src/blenderbim/blenderbim/bim/module/model/prop.py index 231df15cd8..3bb02d201c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/prop.py +++ b/src/blenderbim/blenderbim/bim/module/model/prop.py @@ -133,7 +133,7 @@ class BIMModelProperties(PropertyGroup): z: bpy.props.FloatProperty(name="Z", default=0.5, subtype="DISTANCE", description="Size by Z axis for the opening") # Used for things like walls, doors, flooring, skirting, etc rl1: bpy.props.FloatProperty(name="RL", default=1, subtype="DISTANCE", description="Z offset for walls") - # Used for things like windows, other hosted furniture + # Used for things like windows, other hosted furniture, and MEP rl2: bpy.props.FloatProperty(name="RL", default=1, subtype="DISTANCE", description="Z offset for windows") # Used for plan calculation points such as in room generation rl3: bpy.props.FloatProperty(name="RL", default=1, subtype="DISTANCE", description="Z offset for space calculation") diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index b8b8e74853..1434c68e4f 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -248,7 +248,16 @@ class BimToolUI: elif cls.props.ifc_class in ("IfcDoorType", "IfcDoorStyle"): row = cls.layout.row(align=True) row.prop(data=cls.props, property="rl1", text="RL") - elif cls.props.ifc_class in ("IfcWindowType", "IfcWindowStyle", "IfcDoorType", "IfcDoorStyle"): + elif cls.props.ifc_class in ( + "IfcWindowType", + "IfcWindowStyle", + "IfcDoorType", + "IfcDoorStyle", + "IfcDuctSegmentType", + "IfcPipeSegmentType", + "IfcCableCarrierSegmentType", + "IfcCableSegmentType", + ): row = cls.layout.row(align=True) row.prop(data=cls.props, property="rl2", text="RL") elif cls.props.ifc_class in ("IfcSpaceType"):