Merge pull request #7619 from falken10vdl/MEP-Segment-tool-add-rectangular-hollow-profile

MEP-Segment-tool-add-rectangular-hollow-and-U-shape-profile
This commit is contained in:
falken10vdl
2026-02-01 09:00:14 +01:00
committed by GitHub
2 changed files with 100 additions and 47 deletions
+67 -47
View File
@@ -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
@@ -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"