From f6cb6c8b21db8cbaaf2e6209c70655222965c72c Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 6 Feb 2023 14:52:38 +0500 Subject: [PATCH] Accepting predefined type for windows/stairs/doors from type manager Also assigned layout name property for windows/doors --- src/blenderbim/blenderbim/bim/module/model/door.py | 4 ++++ src/blenderbim/blenderbim/bim/module/model/stair.py | 3 ++- src/blenderbim/blenderbim/bim/module/model/window.py | 8 +++++++- src/blenderbim/blenderbim/bim/module/type/operator.py | 10 +++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/door.py b/src/blenderbim/blenderbim/bim/module/model/door.py index dc36918425..e534ed8609 100644 --- a/src/blenderbim/blenderbim/bim/module/model/door.py +++ b/src/blenderbim/blenderbim/bim/module/model/door.py @@ -48,7 +48,9 @@ V = lambda *x: Vector([float(i) for i in x]) def update_door_modifier_representation(context): obj = context.active_object props = obj.BIMDoorProperties + ifc_element = tool.Ifc.get_entity(obj) ifc_file = tool.Ifc.get() + representation_data = { "operation_type": props.door_type, "overall_height": props.overall_height, @@ -99,6 +101,8 @@ def update_door_modifier_representation(context): model_representation = ifcopenshell.api.run("geometry.add_door_representation", ifc_file, **representation_data) replace_ifc_representation_for_object(ifc_file, ifc_context, obj, model_representation) + ifc_element.OperationType = props.door_type + def create_bm_door_lining(bm, size: Vector, thickness: Vector, position:Vector=V(0,0,0).freeze()): """`thickness` of the profile is defined as list in the following order: `(SIDE, TOP)` diff --git a/src/blenderbim/blenderbim/bim/module/model/stair.py b/src/blenderbim/blenderbim/bim/module/model/stair.py index 8424f747ef..f74043c7db 100644 --- a/src/blenderbim/blenderbim/bim/module/model/stair.py +++ b/src/blenderbim/blenderbim/bim/module/model/stair.py @@ -248,6 +248,8 @@ class BIM_OT_add_clever_stair(Operator): should_add_representation=True, context=body_context, ) + element.PredefinedType = "STRAIGHT" + bpy.ops.object.select_all(action="DESELECT") bpy.context.view_layer.objects.active = None bpy.context.view_layer.objects.active = obj @@ -296,7 +298,6 @@ class AddStair(bpy.types.Operator, tool.Ifc.Operator): update_stair_modifier(context) # update IfcStairFlight properties - element.PredefinedType = "STRAIGHT" if element.is_a("IfcStairFlight"): element.NumberOfRisers = props.number_of_treads + 1 element.NumberOfTreads = props.number_of_treads diff --git a/src/blenderbim/blenderbim/bim/module/model/window.py b/src/blenderbim/blenderbim/bim/module/model/window.py index 2d588c4ab4..86dfc44803 100644 --- a/src/blenderbim/blenderbim/bim/module/model/window.py +++ b/src/blenderbim/blenderbim/bim/module/model/window.py @@ -46,8 +46,10 @@ V = lambda *x: Vector([float(i) for i in x]) def update_window_modifier_representation(context): obj = context.active_object + ifc_element = tool.Ifc.get_entity(obj) props = obj.BIMWindowProperties ifc_file = tool.Ifc.get() + representation_data = { "partition_type": props.window_type, "overall_height": props.overall_height, @@ -82,12 +84,14 @@ def update_window_modifier_representation(context): "geometry.add_window_representation", ifc_file, **representation_data ) replace_ifc_representation_for_object(ifc_file, ifc_context, obj, elevation_representation) - + # MODEL_VIEW representation ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW") representation_data["context"] = ifc_context model_representation = ifcopenshell.api.run("geometry.add_window_representation", ifc_file, **representation_data) replace_ifc_representation_for_object(ifc_file, ifc_context, obj, model_representation) + ifc_element.PartitioningType = props.window_type + def create_bm_window_frame(bm, size: Vector, thickness: Vector, position: Vector = V(0,0,0)): @@ -350,6 +354,8 @@ class BIM_OT_add_window(Operator): ifc_class="IfcWindow", should_add_representation=False ) + element.PredefinedType = "WINDOW" + bpy.ops.object.select_all(action="DESELECT") bpy.context.view_layer.objects.active = None bpy.context.view_layer.objects.active = obj diff --git a/src/blenderbim/blenderbim/bim/module/type/operator.py b/src/blenderbim/blenderbim/bim/module/type/operator.py index 5cb5da0833..e1b182b1d3 100644 --- a/src/blenderbim/blenderbim/bim/module/type/operator.py +++ b/src/blenderbim/blenderbim/bim/module/type/operator.py @@ -283,7 +283,13 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator): mesh = bpy.data.meshes.new("IfcWindow") obj = bpy.data.objects.new("TYPEX", mesh) element = blenderbim.core.root.assign_class( - tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindowType", should_add_representation=False + tool.Ifc, + tool.Collector, + tool.Root, + obj=obj, + predefined_type=predefined_type, + ifc_class="IfcWindowType", + should_add_representation=False ) bpy.ops.object.select_all(action="DESELECT") bpy.context.view_layer.objects.active = None @@ -298,6 +304,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator): tool.Collector, tool.Root, obj=obj, + predefined_type=predefined_type, ifc_class="IfcDoorType", should_add_representation=False ) @@ -315,6 +322,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator): tool.Collector, tool.Root, obj=obj, + predefined_type=predefined_type, ifc_class="IfcStairFlightType", should_add_representation=True, context=body,