diff --git a/src/bonsai/bonsai/bim/module/root/data.py b/src/bonsai/bonsai/bim/module/root/data.py index 66412e7d48..50f3248d8f 100644 --- a/src/bonsai/bonsai/bim/module/root/data.py +++ b/src/bonsai/bonsai/bim/module/root/data.py @@ -134,23 +134,55 @@ class IfcClassData: return [("FACE", "Face", "A planar face surface")] templates = [ ("EMPTY", "No Geometry", "Start with an empty object"), - None, - ( - "OBJ", - "Tessellation From Object", - "Use an object as a template to create a new tessellation", - ), - ( - "MESH", - "Custom Tessellation", - "Create a basic tessellated or faceted cube", - ), - ( - "EXTRUSION", - "Custom Extruded Solid", - "An extrusion from an arbitrary profile", - ), ] + + if ifc_class in ("IfcWindowType", "IfcWindowStyle", "IfcWindow"): + templates.extend([None, ("WINDOW", "Window", "Parametric window")]) + elif ifc_class in ("IfcDoorType", "IfcDoorStyle", "IfcDoor"): + templates.extend([None, ("DOOR", "Door", "Parametric door")]) + elif ifc_class in ("IfcStairType", "IfcStairFlightType", "IfcStair", "IfcStairFlight"): + templates.extend([None, ("STAIR", "Stair", "Parametric stair")]) + elif ifc_class in ("IfcRailingType", "IfcRailing"): + templates.extend([None, ("RAILING", "Railing", "Parametric railing")]) + elif ifc_class in ("IfcRoofType", "IfcRoof", "IfcSlabType", "IfcSlab", "IfcCovering", "IfcCoveringType"): + templates.extend([None, ("ROOF", "Roof", "Parametric roof with a constant pitch")]) + elif ifc_class and "Segment" in ifc_class: + templates.extend( + ( + None, + ( + "FLOW_SEGMENT_RECTANGULAR", + "Rectangular Distribution Segment", + "Works similarly to Profile, has distribution ports", + ), + ( + "FLOW_SEGMENT_RECTANGULAR_HOLLOW", + "Rectangular Hollow Distribution Segment", + "Works similarly to Profile, has distribution ports", + ), + ( + "FLOW_SEGMENT_CIRCULAR", + "Circular Distribution Segment", + "Works similarly to Profile, has distribution ports", + ), + ( + "FLOW_SEGMENT_CIRCULAR_HOLLOW", + "Circular Hollow Distribution Segment", + "Works similarly to Profile, has distribution ports", + ), + ) + ) + if (ifc_class and "IfcCableCarrierSegment" in ifc_class): + templates.extend( + ( + ( + "FLOW_SEGMENT_U_SHAPE", + "U-Shape Distribution Segment", + "Uses IfcUShapeProfileDef, has distribution ports", + ), + ) + ) + if ifc_class.endswith("Type") or ifc_class.endswith("Style"): templates.extend( [ @@ -172,38 +204,26 @@ class IfcClassData: ), ] ) - if ifc_class in ("IfcWindowType", "IfcWindowStyle", "IfcWindow"): - templates.extend([None, ("WINDOW", "Window", "Parametric window")]) - elif ifc_class in ("IfcDoorType", "IfcDoorStyle", "IfcDoor"): - templates.extend([None, ("DOOR", "Door", "Parametric door")]) - elif ifc_class in ("IfcStairType", "IfcStairFlightType", "IfcStair", "IfcStairFlight"): - templates.extend([None, ("STAIR", "Stair", "Parametric stair")]) - elif ifc_class in ("IfcRailingType", "IfcRailing"): - templates.extend([None, ("RAILING", "Railing", "Parametric railing")]) - elif ifc_class in ("IfcRoofType", "IfcRoof", "IfcSlabType", "IfcSlab", "IfcCovering", "IfcCoveringType"): - templates.extend([None, ("ROOF", "Roof", "Parametric roof with a constant pitch")]) - elif ifc_class and "Segment" in ifc_class: - templates.extend( + templates.extend( + [ + None, ( - None, - ( - "FLOW_SEGMENT_RECTANGULAR", - "Rectangular Distribution Segment", - "Works similarly to Profile, has distribution ports", - ), - ( - "FLOW_SEGMENT_CIRCULAR", - "Circular Distribution Segment", - "Works similarly to Profile, has distribution ports", - ), - ( - "FLOW_SEGMENT_CIRCULAR_HOLLOW", - "Circular Hollow Distribution Segment", - "Works similarly to Profile, has distribution ports", - ), - ) - ) - + "OBJ", + "Tessellation From Object", + "Use an object as a template to create a new tessellation", + ), + ( + "MESH", + "Custom Tessellation", + "Create a basic tessellated or faceted cube", + ), + ( + "EXTRUSION", + "Custom Extruded Solid", + "An extrusion from an arbitrary profile", + ), + ] + ) return templates @classmethod diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index a2ac73f200..983429d311 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -697,6 +697,24 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator): XDim=default_x_dim / unit_scale, YDim=default_y_dim / unit_scale, ) + elif representation_template == "FLOW_SEGMENT_RECTANGULAR_HOLLOW": + default_x_dim = 0.4 + default_y_dim = 0.2 + default_thickness = 0.005 + default_inner_fillet_radius = 0.005 + default_outer_fillet_radius = 0.005 + profile_name = f"{props.ifc_class}-{default_x_dim*1000}x{default_y_dim*1000}x{default_thickness*1000}" + profile = tool.Ifc.get().create_entity( + "IfcRectangleHollowProfileDef", + ProfileName=profile_name, + ProfileType="AREA", + XDim=default_x_dim / unit_scale, + YDim=default_y_dim / unit_scale, + WallThickness=default_thickness / unit_scale, + InnerFilletRadius=default_inner_fillet_radius / unit_scale, + OuterFilletRadius=default_outer_fillet_radius / unit_scale, + ) + elif representation_template == "FLOW_SEGMENT_CIRCULAR": default_diameter = 0.1 profile_name = f"{props.ifc_class}-{default_diameter*1000}" @@ -717,6 +735,21 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator): Radius=(default_diameter / 2) / unit_scale, WallThickness=default_thickness, ) + elif representation_template == "FLOW_SEGMENT_U_SHAPE": + default_depth = 0.4 + default_flange_width = 0.2 + default_web_thickness = 0.005 + default_flange_thickness = 0.005 + profile_name = f"{props.ifc_class}-{default_depth*1000}x{default_flange_width*1000}x{default_web_thickness*1000}x{default_flange_thickness*1000}" + profile = tool.Ifc.get().create_entity( + "IfcUShapeProfileDef", + ProfileName=profile_name, + ProfileType="AREA", + Depth=default_depth / unit_scale, + FlangeWidth=default_flange_width / unit_scale, + WebThickness=default_web_thickness / unit_scale, + FlangeThickness=default_flange_thickness / unit_scale, + ) rel = ifcopenshell.api.material.assign_material( tool.Ifc.get(), products=[element], type="IfcMaterialProfileSet"