Support for door/window/stair modifiers in ifc2x3

This commit is contained in:
Andrej730
2023-06-29 17:41:34 +05:00
parent ced6326bfd
commit 57f43fe608
5 changed files with 35 additions and 18 deletions
@@ -128,6 +128,7 @@ def update_door_modifier_representation(context):
) )
# type attributes # type attributes
if tool.Ifc.get_schema() != "IFC2X3":
element.OperationType = props.door_type element.OperationType = props.door_type
# occurences attributes # occurences attributes
@@ -486,6 +487,7 @@ class BIM_OT_add_door(bpy.types.Operator, tool.Ifc.Operator):
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcDoor", should_add_representation=False tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcDoor", should_add_representation=False
) )
if tool.Ifc.get_schema() != "IFC2X3":
element.PredefinedType = "DOOR" element.PredefinedType = "DOOR"
bpy.ops.object.select_all(action="DESELECT") bpy.ops.object.select_all(action="DESELECT")
@@ -507,8 +509,8 @@ class AddDoor(bpy.types.Operator, tool.Ifc.Operator):
element = tool.Ifc.get_entity(obj) element = tool.Ifc.get_entity(obj)
props = obj.BIMDoorProperties props = obj.BIMDoorProperties
if element.is_a() not in ("IfcDoor", "IfcDoorType"): if element.is_a() not in ("IfcDoor", "IfcDoorType", "IfcDoorStyle"):
self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType type to add a door.") self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType/IfcDoorStyle type to add a door.")
return {"CANCELLED"} return {"CANCELLED"}
door_data = props.get_general_kwargs(convert_to_project_units=True) door_data = props.get_general_kwargs(convert_to_project_units=True)
@@ -232,8 +232,15 @@ class FilledOpeningGenerator:
curve_3d = ifcopenshell.util.representation.resolve_representation(profile).Items[0] curve_3d = ifcopenshell.util.representation.resolve_representation(profile).Items[0]
def get_curve_2d_from_3d(curve_3d): def get_curve_2d_from_3d(curve_3d):
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_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_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) ifc_curve = ifc_file.createIfcIndexedPolyCurve(Points=ifc_points, Segments=ifc_segments)
return ifc_curve return ifc_curve
@@ -250,6 +250,7 @@ def update_ifc_stair_props(obj):
props = obj.BIMStairProperties props = obj.BIMStairProperties
ifc_file = tool.Ifc.get() ifc_file = tool.Ifc.get()
if tool.Ifc.get_schema() != "IFC2X3":
element.PredefinedType = "STRAIGHT" element.PredefinedType = "STRAIGHT"
number_of_risers = props.number_of_treads + 1 number_of_risers = props.number_of_treads + 1
# update IfcStairFlight properties (seems already deprecated but keep it for now) # update IfcStairFlight properties (seems already deprecated but keep it for now)
@@ -260,7 +261,11 @@ def update_ifc_stair_props(obj):
tread_length = props.tread_depth / si_conversion tread_length = props.tread_depth / si_conversion
if element.is_a("IfcStairFlight"): if element.is_a("IfcStairFlight"):
if tool.Ifc.get_schema() == "IFC2X3":
element.NumberOfRiser = number_of_risers
else:
element.NumberOfRisers = number_of_risers element.NumberOfRisers = number_of_risers
element.NumberOfTreads = props.number_of_treads element.NumberOfTreads = props.number_of_treads
element.RiserHeight = riser_height element.RiserHeight = riser_height
element.TreadLength = tread_length element.TreadLength = tread_length
@@ -330,6 +335,7 @@ class BIM_OT_add_clever_stair(bpy.types.Operator, tool.Ifc.Operator):
should_add_representation=True, should_add_representation=True,
context=body_context, context=body_context,
) )
if tool.Ifc.get_schema() != "IFC2X3":
element.PredefinedType = "STRAIGHT" element.PredefinedType = "STRAIGHT"
bpy.ops.object.select_all(action="DESELECT") bpy.ops.object.select_all(action="DESELECT")
@@ -167,6 +167,7 @@ def update_window_modifier_representation(context):
) )
# type attributes # type attributes
if tool.Ifc.get_schema() != "IFC2X3":
element.PartitioningType = props.window_type element.PartitioningType = props.window_type
# occurences attributes # occurences attributes
@@ -455,6 +456,7 @@ class BIM_OT_add_window(bpy.types.Operator, tool.Ifc.Operator):
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindow", should_add_representation=False tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindow", should_add_representation=False
) )
if tool.Ifc.get_schema() != "IFC2X3":
element.PredefinedType = "WINDOW" element.PredefinedType = "WINDOW"
bpy.ops.object.select_all(action="DESELECT") bpy.ops.object.select_all(action="DESELECT")
@@ -476,8 +478,8 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator):
element = tool.Ifc.get_entity(obj) element = tool.Ifc.get_entity(obj)
props = obj.BIMWindowProperties props = obj.BIMWindowProperties
if element.is_a() not in ("IfcWindow", "IfcWindowType"): if element.is_a() not in ("IfcWindow", "IfcWindowType", "IfcWindowStyle"):
self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType type to add a window.") self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType/IfcWindowStyle type to add a window.")
return {"CANCELLED"} return {"CANCELLED"}
window_data = props.get_general_kwargs(convert_to_project_units=True) window_data = props.get_general_kwargs(convert_to_project_units=True)
@@ -329,8 +329,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
tool.Collector, tool.Collector,
tool.Root, tool.Root,
obj=obj, obj=obj,
predefined_type=predefined_type, predefined_type=predefined_type if tool.Ifc.get_schema() != "IFC2X3" else None,
ifc_class="IfcWindowType", ifc_class="IfcWindowType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcWindowStyle",
should_add_representation=False, should_add_representation=False,
) )
bpy.ops.object.select_all(action="DESELECT") bpy.ops.object.select_all(action="DESELECT")
@@ -347,8 +347,8 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
tool.Collector, tool.Collector,
tool.Root, tool.Root,
obj=obj, obj=obj,
predefined_type=predefined_type, predefined_type=predefined_type if tool.Ifc.get_schema() != "IFC2X3" else None,
ifc_class="IfcDoorType", ifc_class="IfcDoorType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcDoorStyle",
should_add_representation=False, should_add_representation=False,
) )
bpy.ops.object.select_all(action="DESELECT") bpy.ops.object.select_all(action="DESELECT")