diff --git a/src/bonsai/bonsai/bim/module/model/data.py b/src/bonsai/bonsai/bim/module/model/data.py index fd5528e910..66fc0113ce 100644 --- a/src/bonsai/bonsai/bim/module/model/data.py +++ b/src/bonsai/bonsai/bim/module/model/data.py @@ -76,6 +76,7 @@ class AuthoringData: cls.data["active_representation_type"] = cls.active_representation_type() cls.data["boundary_class"] = cls.boundary_class() cls.data["selected_material_usages"] = cls.selected_material_usages() + cls.data["type_template"] = cls.type_template() @classmethod def default_container(cls) -> str | None: @@ -139,6 +140,65 @@ class AuthoringData: element = tool.Ifc.get().by_id(int(relating_type_id)) return cls.type_thumbnails.get(element.id(), None) or 0 + @classmethod + def type_template(cls): + type_class = cls.props.type_class + templates = [ + ( + "MESH", + "Custom Mesh", + "Use as a representation currently active object mesh or default cube if no object selected", + ), + ( + "LAYERSET_AXIS2", + "Vertical Layers", + "For objects similar to walls, will automatically add IfcMaterialLayerSet", + ), + ( + "LAYERSET_AXIS3", + "Horizontal Layers", + "For objects similar to slabs, will automatically add IfcMaterialLayerSet", + ), + ( + "PROFILESET", + "Extruded Profile", + "Create profile type object, automatically defines IfcMaterialProfileSet with the first profile from library", + ), + ("EMPTY", "Non-Geometric Type", "Start with an empty object"), + ] + if not type_class: + pass + elif type_class == "IfcWindowType": + templates.append(("WINDOW", "Window", "Parametric window")) + elif type_class == "IfcDoorType": + templates.append(("DOOR", "Door", "Parametric door")) + elif type_class == "IfcRailingType": + templates.append(("RAILING", "Railing", "Parametric railing")) + elif type_class == "IfcRoofType": + templates.append(("Roof", "Window", "Parametric window")) + + templates.extend( + ( + ( + "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", + ), + ) + ) + + return templates + @classmethod def total_types(cls): type_class = cls.props.type_class diff --git a/src/bonsai/bonsai/bim/module/model/prop.py b/src/bonsai/bonsai/bim/module/model/prop.py index 8cba3c223f..07b7be06a8 100644 --- a/src/bonsai/bonsai/bim/module/model/prop.py +++ b/src/bonsai/bonsai/bim/module/model/prop.py @@ -56,6 +56,12 @@ def get_type_predefined_type(self, context): return AuthoringData.data["type_predefined_type"] +def get_type_template(self, context): + if not AuthoringData.is_loaded: + AuthoringData.load() + return AuthoringData.data["type_template"] + + def update_ifc_class(self, context): bpy.ops.bim.load_type_thumbnails(ifc_class=self.ifc_class) AuthoringData.data["relating_type_id"] = AuthoringData.relating_type_id() @@ -71,6 +77,7 @@ def update_type_class(self, context): AuthoringData.data["next_page"] = AuthoringData.next_page() AuthoringData.data["paginated_relating_types"] = AuthoringData.paginated_relating_types() AuthoringData.data["type_predefined_type"] = AuthoringData.type_predefined_type() + AuthoringData.data["type_template"] = AuthoringData.type_template() type_class = self.type_class if (type_class, type_class, "") in get_ifc_class(self, context): @@ -166,25 +173,7 @@ class BIMModelProperties(PropertyGroup): x_angle: bpy.props.FloatProperty(name="X Angle", default=0, subtype="ANGLE", min=-pi / 180 * 89, max=pi / 180 * 89) type_page: bpy.props.IntProperty(name="Type Page", default=1, update=update_type_page) # fmt: off - type_template: bpy.props.EnumProperty( - items=( - ("MESH", "Custom Mesh", "Use as a representation currently active object mesh or default cube if no object selected"), - ("LAYERSET_AXIS2", "Vertical Layers", "For objects similar to walls, will automatically add IfcMaterialLayerSet"), - ("LAYERSET_AXIS3", "Horizontal Layers", "For objects similar to slabs, will automatically add IfcMaterialLayerSet"), - ("PROFILESET", "Extruded Profile", "Create profile type object, automatically defines IfcMaterialProfileSet with the first profile from library"), - ("EMPTY", "Non-Geometric Type", "Start with an empty object"), - ("WINDOW", "Window", "Parametric window"), - ("DOOR", "Door", "Parametric door"), - ("STAIR", "Stair", "Parametric stair"), - ("RAILING", "Railing", "Parametric railing"), - ("ROOF", "Roof", "Parametric roof"), - ("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", - ) + type_template: bpy.props.EnumProperty(items=get_type_template, name="Type Template", default=0) # fmt: on type_class: bpy.props.EnumProperty(items=get_type_class, name="IFC Class", update=update_type_class) type_predefined_type: bpy.props.EnumProperty(items=get_type_predefined_type, name="Predefined Type", default=None) diff --git a/src/bonsai/bonsai/bim/module/model/ui.py b/src/bonsai/bonsai/bim/module/model/ui.py index 9b924c8c21..7f5d0e880b 100644 --- a/src/bonsai/bonsai/bim/module/model/ui.py +++ b/src/bonsai/bonsai/bim/module/model/ui.py @@ -67,8 +67,7 @@ class LaunchTypeManager(bpy.types.Operator): props = context.scene.BIMModelProperties row = self.layout.row(align=True) - prop_with_search(row, props, "type_class", text="") - row.operator("bim.purge_unused_types", icon="TRASH", text="") + prop_with_search(row, props, "type_class", text="", should_click_ok_to_validate=True) columns = self.layout.column_flow(columns=3) row = columns.row()