From 98edb5a34c4a7c4c95bb3ae7ebe5e86e75dab916 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 29 Jul 2024 19:50:21 +1000 Subject: [PATCH] Display the default container in the UI when creating new types --- src/blenderbim/blenderbim/bim/module/model/data.py | 10 ++++++++++ .../blenderbim/bim/module/model/workspace.py | 1 + src/blenderbim/blenderbim/bim/module/spatial/data.py | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/data.py b/src/blenderbim/blenderbim/bim/module/model/data.py index 01d0dfcda9..ea6f6ae3d9 100644 --- a/src/blenderbim/blenderbim/bim/module/model/data.py +++ b/src/blenderbim/blenderbim/bim/module/model/data.py @@ -50,6 +50,7 @@ class AuthoringData: cls.props = bpy.context.scene.BIMModelProperties if ifc_element_type: cls.ifc_element_type = None if ifc_element_type == "all" else ifc_element_type + cls.data["default_container"] = cls.default_container() cls.data["ifc_element_type"] = cls.ifc_element_type cls.data["ifc_classes"] = cls.ifc_classes() cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes() @@ -74,6 +75,15 @@ class AuthoringData: cls.data["boundary_class"] = cls.boundary_class() cls.data["selected_material_usages"] = cls.selected_material_usages() + @classmethod + def default_container(cls) -> str | None: + props = bpy.context.scene.BIMSpatialDecompositionProperties + if props.default_container: + try: + return tool.Ifc.get().by_id(props.default_container).Name + except: + pass + @classmethod def boundary_class(cls): declaration = tool.Ifc.schema().declaration_by_name("IfcRelSpaceBoundary") diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index 33b5bb0845..4719c5e59d 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -503,6 +503,7 @@ class BimToolUI: def draw_type_selection_interface(cls): # shared by both sidebar and header row = cls.layout.row(align=True) + row.label(text=f"Container: {AuthoringData.data['default_container']}", icon="OUTLINER_COLLECTION") if AuthoringData.data["ifc_classes"]: if not AuthoringData.data["ifc_element_type"]: row.label(text="", icon="FILE_VOLUME") diff --git a/src/blenderbim/blenderbim/bim/module/spatial/data.py b/src/blenderbim/blenderbim/bim/module/spatial/data.py index 63fe167a81..09617ca9b2 100644 --- a/src/blenderbim/blenderbim/bim/module/spatial/data.py +++ b/src/blenderbim/blenderbim/bim/module/spatial/data.py @@ -97,7 +97,7 @@ class SpatialDecompositionData: } @classmethod - def default_container(cls) -> str: + def default_container(cls) -> str | None: props = bpy.context.scene.BIMSpatialDecompositionProperties if props.default_container: try: