From 57f43fe608e4dd023443547445cb7bf869fb70b1 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 29 Jun 2023 17:41:34 +0500 Subject: [PATCH] Support for door/window/stair modifiers in ifc2x3 --- src/blenderbim/blenderbim/bim/module/model/door.py | 10 ++++++---- .../blenderbim/bim/module/model/opening.py | 13 ++++++++++--- src/blenderbim/blenderbim/bim/module/model/stair.py | 12 +++++++++--- .../blenderbim/bim/module/model/window.py | 10 ++++++---- .../blenderbim/bim/module/type/operator.py | 8 ++++---- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/door.py b/src/blenderbim/blenderbim/bim/module/model/door.py index 8273ce4393..99aa50f6c9 100644 --- a/src/blenderbim/blenderbim/bim/module/model/door.py +++ b/src/blenderbim/blenderbim/bim/module/model/door.py @@ -128,7 +128,8 @@ def update_door_modifier_representation(context): ) # type attributes - element.OperationType = props.door_type + if tool.Ifc.get_schema() != "IFC2X3": + element.OperationType = props.door_type # occurences attributes occurences = tool.Ifc.get_all_element_occurences(element) @@ -486,7 +487,8 @@ class BIM_OT_add_door(bpy.types.Operator, tool.Ifc.Operator): element = blenderbim.core.root.assign_class( tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcDoor", should_add_representation=False ) - element.PredefinedType = "DOOR" + if tool.Ifc.get_schema() != "IFC2X3": + element.PredefinedType = "DOOR" bpy.ops.object.select_all(action="DESELECT") bpy.context.view_layer.objects.active = None @@ -507,8 +509,8 @@ class AddDoor(bpy.types.Operator, tool.Ifc.Operator): element = tool.Ifc.get_entity(obj) props = obj.BIMDoorProperties - if element.is_a() not in ("IfcDoor", "IfcDoorType"): - self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType type to add a door.") + if element.is_a() not in ("IfcDoor", "IfcDoorType", "IfcDoorStyle"): + self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType/IfcDoorStyle type to add a door.") return {"CANCELLED"} door_data = props.get_general_kwargs(convert_to_project_units=True) diff --git a/src/blenderbim/blenderbim/bim/module/model/opening.py b/src/blenderbim/blenderbim/bim/module/model/opening.py index 6378aaa297..1d3ca9dbce 100644 --- a/src/blenderbim/blenderbim/bim/module/model/opening.py +++ b/src/blenderbim/blenderbim/bim/module/model/opening.py @@ -232,9 +232,16 @@ class FilledOpeningGenerator: curve_3d = ifcopenshell.util.representation.resolve_representation(profile).Items[0] def get_curve_2d_from_3d(curve_3d): - ifc_segments = [shape_builder.deep_copy(s) for s in curve_3d.Segments] - ifc_points = ifc_file.createIfcCartesianPointList2D([Vector(p).xz for p in curve_3d.Points.CoordList]) - ifc_curve = ifc_file.createIfcIndexedPolyCurve(Points=ifc_points, Segments=ifc_segments) + if tool.Ifc.get_schema() == "IFC2X3": + coords = [Vector(p).xz for p in shape_builder.get_polyline_coords(curve_3d)] + ifc_curve = shape_builder.polyline(coords, closed=True) + else: + # using different algorithm to keep arc segments possible in the future + ifc_segments = [shape_builder.deep_copy(s) for s in curve_3d.Segments] + ifc_points = ifc_file.createIfcCartesianPointList2D( + [Vector(p).xz for p in curve_3d.Points.CoordList] + ) + ifc_curve = ifc_file.createIfcIndexedPolyCurve(Points=ifc_points, Segments=ifc_segments) return ifc_curve extrusion = shape_builder.extrude( diff --git a/src/blenderbim/blenderbim/bim/module/model/stair.py b/src/blenderbim/blenderbim/bim/module/model/stair.py index 52d90348e2..04b5836e14 100644 --- a/src/blenderbim/blenderbim/bim/module/model/stair.py +++ b/src/blenderbim/blenderbim/bim/module/model/stair.py @@ -250,7 +250,8 @@ def update_ifc_stair_props(obj): props = obj.BIMStairProperties ifc_file = tool.Ifc.get() - element.PredefinedType = "STRAIGHT" + if tool.Ifc.get_schema() != "IFC2X3": + element.PredefinedType = "STRAIGHT" number_of_risers = props.number_of_treads + 1 # update IfcStairFlight properties (seems already deprecated but keep it for now) # http://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcStairFlight.htm @@ -260,7 +261,11 @@ def update_ifc_stair_props(obj): tread_length = props.tread_depth / si_conversion if element.is_a("IfcStairFlight"): - element.NumberOfRisers = number_of_risers + if tool.Ifc.get_schema() == "IFC2X3": + element.NumberOfRiser = number_of_risers + else: + element.NumberOfRisers = number_of_risers + element.NumberOfTreads = props.number_of_treads element.RiserHeight = riser_height element.TreadLength = tread_length @@ -330,7 +335,8 @@ class BIM_OT_add_clever_stair(bpy.types.Operator, tool.Ifc.Operator): should_add_representation=True, context=body_context, ) - element.PredefinedType = "STRAIGHT" + if tool.Ifc.get_schema() != "IFC2X3": + element.PredefinedType = "STRAIGHT" bpy.ops.object.select_all(action="DESELECT") bpy.context.view_layer.objects.active = None diff --git a/src/blenderbim/blenderbim/bim/module/model/window.py b/src/blenderbim/blenderbim/bim/module/model/window.py index fea2fad5d5..3f4f7ee926 100644 --- a/src/blenderbim/blenderbim/bim/module/model/window.py +++ b/src/blenderbim/blenderbim/bim/module/model/window.py @@ -167,7 +167,8 @@ def update_window_modifier_representation(context): ) # type attributes - element.PartitioningType = props.window_type + if tool.Ifc.get_schema() != "IFC2X3": + element.PartitioningType = props.window_type # occurences attributes occurences = tool.Ifc.get_all_element_occurences(element) @@ -455,7 +456,8 @@ class BIM_OT_add_window(bpy.types.Operator, tool.Ifc.Operator): element = blenderbim.core.root.assign_class( tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindow", should_add_representation=False ) - element.PredefinedType = "WINDOW" + if tool.Ifc.get_schema() != "IFC2X3": + element.PredefinedType = "WINDOW" bpy.ops.object.select_all(action="DESELECT") bpy.context.view_layer.objects.active = None @@ -476,8 +478,8 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator): element = tool.Ifc.get_entity(obj) props = obj.BIMWindowProperties - if element.is_a() not in ("IfcWindow", "IfcWindowType"): - self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType type to add a window.") + if element.is_a() not in ("IfcWindow", "IfcWindowType", "IfcWindowStyle"): + self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType/IfcWindowStyle type to add a window.") return {"CANCELLED"} window_data = props.get_general_kwargs(convert_to_project_units=True) diff --git a/src/blenderbim/blenderbim/bim/module/type/operator.py b/src/blenderbim/blenderbim/bim/module/type/operator.py index 8532b2717b..dffd55a617 100644 --- a/src/blenderbim/blenderbim/bim/module/type/operator.py +++ b/src/blenderbim/blenderbim/bim/module/type/operator.py @@ -329,8 +329,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator): tool.Collector, tool.Root, obj=obj, - predefined_type=predefined_type, - ifc_class="IfcWindowType", + predefined_type=predefined_type if tool.Ifc.get_schema() != "IFC2X3" else None, + ifc_class="IfcWindowType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcWindowStyle", should_add_representation=False, ) bpy.ops.object.select_all(action="DESELECT") @@ -347,8 +347,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator): tool.Collector, tool.Root, obj=obj, - predefined_type=predefined_type, - ifc_class="IfcDoorType", + predefined_type=predefined_type if tool.Ifc.get_schema() != "IFC2X3" else None, + ifc_class="IfcDoorType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcDoorStyle", should_add_representation=False, ) bpy.ops.object.select_all(action="DESELECT")