You can now toggle recursive children in the spatial tree

This commit is contained in:
Dion Moult
2024-07-15 23:56:35 +10:00
parent 215866cf30
commit 83085ba3c1
3 changed files with 20 additions and 6 deletions
@@ -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):
@@ -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",
+7 -1
View File
@@ -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"