diff --git a/src/blenderbim/blenderbim/bim/module/spatial/operator.py b/src/blenderbim/blenderbim/bim/module/spatial/operator.py index 14bb84f09d..bd26456c7d 100644 --- a/src/blenderbim/blenderbim/bim/module/spatial/operator.py +++ b/src/blenderbim/blenderbim/bim/module/spatial/operator.py @@ -228,9 +228,15 @@ class SelectDecomposedElements(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.select_decomposed_elements" bl_label = "Select Children" bl_options = {"REGISTER", "UNDO"} + container: bpy.props.IntProperty() + ifc_class: bpy.props.StringProperty() + + @classmethod + def description(cls, context, operator): + return f"Select all elements contained in {operator.ifc_class}" def _execute(self, context): - core.select_decomposed_elements(tool.Spatial) + core.select_decomposed_elements(tool.Spatial, container=tool.Ifc.get().by_id(self.container)) class SetDefaultContainer(bpy.types.Operator, tool.Ifc.Operator): @@ -238,6 +244,7 @@ class SetDefaultContainer(bpy.types.Operator, tool.Ifc.Operator): bl_label = "Set Default Container" bl_options = {"REGISTER", "UNDO"} container: bpy.props.IntProperty() + bl_description = "Set this as the default container that all new elements will be contained in" def _execute(self, context): core.set_default_container(tool.Spatial, container=tool.Ifc.get().by_id(self.container)) diff --git a/src/blenderbim/blenderbim/bim/module/spatial/ui.py b/src/blenderbim/blenderbim/bim/module/spatial/ui.py index 5f9eabf9d7..e6367d0b36 100644 --- a/src/blenderbim/blenderbim/bim/module/spatial/ui.py +++ b/src/blenderbim/blenderbim/bim/module/spatial/ui.py @@ -115,11 +115,10 @@ class BIM_PT_spatial_decomposition(Panel): text=f"Default: {SpatialDecompositionData.data['default_container']}", icon="OUTLINER_COLLECTION", ) - row.operator("bim.import_spatial_decomposition", icon="FILE_REFRESH", text="") else: row = self.layout.row(align=True) row.label(text="Warning: No Default Container", icon="ERROR") - row.operator("bim.import_spatial_decomposition", icon="FILE_REFRESH", text="") + row.operator("bim.import_spatial_decomposition", icon="FILE_REFRESH", text="") if self.props.active_container: ifc_definition_id = self.props.active_container.ifc_definition_id if self.props.active_container else 0 @@ -134,7 +133,11 @@ class BIM_PT_spatial_decomposition(Panel): row.enabled = False op = row.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default") op.container = ifc_definition_id - row.operator("bim.select_decomposed_elements", icon="HIDE_OFF", text=f"Isolate {self.props.active_container.ifc_class}") + row.operator("bim.select_decomposed_elements", icon="FULLSCREEN_EXIT", text="Isolate") + row.operator("bim.select_decomposed_elements", icon="HIDE_OFF", text="") + row.operator("bim.select_decomposed_elements", icon="HIDE_ON", text="") + row.operator("bim.select_decomposed_elements", icon="OBJECT_DATA", text="") + row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="") op = row.operator("bim.delete_container", icon="X", text="") op.container = ifc_definition_id @@ -198,18 +201,22 @@ class BIM_UL_containers_manager(UIList): row.label(text="", icon="BLANK1") if item.ifc_class == "IfcProject": row.label(text="", icon="FILE") - elif item.ifc_class == "IfcSite": - row.label(text="", icon="WORLD") - elif item.ifc_class == "IfcBuilding": - row.label(text="", icon="HOME") - elif item.ifc_class == "IfcBuildingStorey": - row.label(text="", icon="LINENUMBERS_OFF") - elif item.ifc_class == "IfcSpace": - row.label(text="", icon="ANTIALIASED") - elif "Part" in item.ifc_class: - row.label(text="", icon="MOD_FLUID") else: - row.label(text="", icon="META_PLANE") + icon = { + "IfcSite": "WORLD", + "IfcBuilding": "HOME", + "IfcBuildingStorey": "LINENUMBERS_OFF", + "IfcSpace": "ANTIALIASED", + "IfcFacilityPart": "MOD_FLUID", + "IfcBridgePart": "MOD_FLUID", + "IfcFacilityPartCommon": "MOD_FLUID", + "IfcMarinePart": "MOD_FLUID", + "IfcRailwayPart": "MOD_FLUID", + "IfcRoadPart": "MOD_FLUID", + }.get(item.ifc_class, "META_PLANE") + op = row.operator("bim.select_decomposed_elements", icon=icon, text="", emboss=False) + op.ifc_class = item.ifc_class + op.container = item.ifc_definition_id class BIM_UL_elements(UIList): diff --git a/src/blenderbim/blenderbim/core/spatial.py b/src/blenderbim/blenderbim/core/spatial.py index 3c0ca50118..daabd6250a 100644 --- a/src/blenderbim/blenderbim/core/spatial.py +++ b/src/blenderbim/blenderbim/core/spatial.py @@ -152,10 +152,8 @@ def delete_container( spatial.import_spatial_decomposition() -def select_decomposed_elements(spatial: tool.Spatial) -> None: - container = spatial.get_active_container() - if container: - spatial.select_products(spatial.get_decomposed_elements(container)) +def select_decomposed_elements(spatial: tool.Spatial, container: ifcopenshell.entity_instance) -> None: + spatial.select_products(spatial.get_decomposed_elements(container)) def generate_space(ifc: tool.Ifc, model: tool.Model, root: tool.Root, spatial: tool.Spatial, type: tool.Type) -> None: