Easily create a "default" duct / pipe even if you have no demo library.

This commit is contained in:
Dion Moult
2023-08-01 22:34:34 +10:00
parent 120a9f9f3e
commit 4443f484c1
3 changed files with 11 additions and 9 deletions
@@ -100,9 +100,11 @@ class AddDefaultType(bpy.types.Operator, tool.Ifc.Operator):
props.type_predefined_type = "BEAM"
props.type_template = "PROFILESET"
elif self.ifc_element_type == "IfcDuctSegmentType":
return
props.type_predefined_type = "RIGIDSEGMENT"
props.type_template = "FLOW_SEGMENT_RECTANGULAR"
elif self.ifc_element_type == "IfcPipeSegmentType":
return
props.type_predefined_type = "RIGIDSEGMENT"
props.type_template = "FLOW_SEGMENT_CIRCULAR"
bpy.ops.bim.add_type()
@@ -151,9 +151,9 @@ class BIMModelProperties(PropertyGroup):
("STAIR", "Stair", "Parametric stair"),
("RAILING", "Railing", "Parametric railing"),
("ROOF", "Roof", "Parametric roof"),
("DISTRIBUTION_SEGMENT_RECTANGULAR", "Rectangular Distribution Segment", "Works similarly to Profile, has distribution ports"),
("DISTRIBUTION_SEGMENT_CIRCULAR", "Circular Distribution Segment", "Works similarly to Profile, has distribution ports"),
("DISTRIBUTION_SEGMENT_CIRCULAR_HOLLOW", "Circular Hollow Distribution Segment", "Works similarly to Profile, has distribution ports"),
("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"),
),
name="Type Template",
default="MESH",
@@ -282,7 +282,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
axis = "AXIS3"
ifcopenshell.api.run("pset.edit_pset", ifc_file, pset=pset, properties={"LayerSetDirection": axis})
elif template == "PROFILESET" or template.startswith("DISTRIBUTION_SEGMENT_"):
elif template == "PROFILESET" or template.startswith("FLOW_SEGMENT_"):
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
obj = bpy.data.objects.new(name, None)
element = blenderbim.core.root.assign_class(
@@ -312,7 +312,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
)
else:
# NOTE: defaults dims are in meters / mm
if template == "DISTRIBUTION_SEGMENT_RECTANGULAR":
if template == "FLOW_SEGMENT_RECTANGULAR":
default_x_dim = 0.4 / unit_scale
default_y_dim = 0.2 / unit_scale
profile_name = f"{ifc_class}-{default_x_dim*1000}x{default_x_dim*1000}"
@@ -323,13 +323,13 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
XDim=default_x_dim,
YDim=default_y_dim,
)
elif template == "DISTRIBUTION_SEGMENT_CIRCULAR":
elif template == "FLOW_SEGMENT_CIRCULAR":
default_diameter = 0.1 / unit_scale
profile_name = f"{ifc_class}-{default_diameter*1000}"
profile = ifc_file.create_entity(
"IfcCircleProfileDef", ProfileName=profile_name, ProfileType="AREA", Radius=default_diameter / 2
)
elif template == "DISTRIBUTION_SEGMENT_CIRCULAR_HOLLOW":
elif template == "FLOW_SEGMENT_CIRCULAR_HOLLOW":
default_diameter = 0.15 / unit_scale
default_thickness = 0.005 / unit_scale
profile_name = f"{ifc_class}-{default_diameter*1000}x{default_thickness*1000}"