From 83085ba3c19c4c30953ce775bdf33f4b0c390b2f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 15 Jul 2024 23:56:35 +1000 Subject: [PATCH] You can now toggle recursive children in the spatial tree --- src/blenderbim/blenderbim/bim/module/spatial/prop.py | 7 +++++++ src/blenderbim/blenderbim/bim/module/spatial/ui.py | 11 ++++++----- src/blenderbim/blenderbim/tool/spatial.py | 8 +++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/spatial/prop.py b/src/blenderbim/blenderbim/bim/module/spatial/prop.py index 1e1f6916c1..2afee7fa23 100644 --- a/src/blenderbim/blenderbim/bim/module/spatial/prop.py +++ b/src/blenderbim/blenderbim/bim/module/spatial/prop.py @@ -59,6 +59,10 @@ def update_active_container_index(self, context): tool.Spatial.load_contained_elements() +def update_should_include_children(self, context): + tool.Spatial.load_contained_elements() + + def update_relating_container_from_object(self, context): if self.relating_container_object is None or context.active_object is None: return @@ -132,6 +136,9 @@ class BIMSpatialDecompositionProperties(PropertyGroup): total_elements: IntProperty(name="Total Elements") subelement_class: bpy.props.EnumProperty(items=get_subelement_class, name="Subelement Class") default_container: IntProperty(name="Default Container", default=0) + should_include_children: BoolProperty( + name="Should Include Children", default=True, update=update_should_include_children + ) @property def active_container(self): diff --git a/src/blenderbim/blenderbim/bim/module/spatial/ui.py b/src/blenderbim/blenderbim/bim/module/spatial/ui.py index f20166e2c0..5a1372589e 100644 --- a/src/blenderbim/blenderbim/bim/module/spatial/ui.py +++ b/src/blenderbim/blenderbim/bim/module/spatial/ui.py @@ -137,9 +137,6 @@ class BIM_PT_spatial_decomposition(Panel): row.operator("bim.select_decomposed_elements", icon="HIDE_OFF", text="") row.operator("bim.select_decomposed_elements", icon="HIDE_ON", text="") row.operator("bim.select_container", icon="OBJECT_DATA", text="").container = ifc_definition_id - op = row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="") - op.ifc_class = self.props.active_container.ifc_class - op.container = ifc_definition_id op = row.operator("bim.delete_container", icon="X", text="") op.container = ifc_definition_id @@ -157,13 +154,17 @@ class BIM_PT_spatial_decomposition(Panel): return if not self.props.total_elements: - row = self.layout.row() + row = self.layout.row(align=True) row.label(text="No Contained Elements", icon="FILE_3D") + row.prop(self.props, "should_include_children", text="", icon="OUTLINER") return row = self.layout.row(align=True) row.label(text=f"{self.props.total_elements} Contained Elements", icon="FILE_3D") - row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="") + row.prop(self.props, "should_include_children", text="", icon="OUTLINER") + op = row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="") + op.ifc_class = self.props.active_container.ifc_class + op.container = ifc_definition_id self.layout.template_list( "BIM_UL_elements", diff --git a/src/blenderbim/blenderbim/tool/spatial.py b/src/blenderbim/blenderbim/tool/spatial.py index 9ad2994dcf..5102b1f27b 100644 --- a/src/blenderbim/blenderbim/tool/spatial.py +++ b/src/blenderbim/blenderbim/tool/spatial.py @@ -235,7 +235,13 @@ class Spatial(blenderbim.core.tool.Spatial): container = tool.Ifc.get().by_id(container.ifc_definition_id) results = {} - for element in ifcopenshell.util.element.get_contained(container): + if props.should_include_children: + elements = ifcopenshell.util.element.get_decomposition(container, is_recursive=True) + else: + elements = ifcopenshell.util.element.get_contained(container) + for element in elements: + if not element.is_a("IfcElement"): + continue element_type = ifcopenshell.util.element.get_type(element) ifc_class = element.is_a() type_name = element_type.Name or "Unnamed" if element_type else "Untyped"