mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 05:46:51 +00:00
You can now toggle recursive children in the spatial tree
This commit is contained in:
@@ -59,6 +59,10 @@ def update_active_container_index(self, context):
|
|||||||
tool.Spatial.load_contained_elements()
|
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):
|
def update_relating_container_from_object(self, context):
|
||||||
if self.relating_container_object is None or context.active_object is None:
|
if self.relating_container_object is None or context.active_object is None:
|
||||||
return
|
return
|
||||||
@@ -132,6 +136,9 @@ class BIMSpatialDecompositionProperties(PropertyGroup):
|
|||||||
total_elements: IntProperty(name="Total Elements")
|
total_elements: IntProperty(name="Total Elements")
|
||||||
subelement_class: bpy.props.EnumProperty(items=get_subelement_class, name="Subelement Class")
|
subelement_class: bpy.props.EnumProperty(items=get_subelement_class, name="Subelement Class")
|
||||||
default_container: IntProperty(name="Default Container", default=0)
|
default_container: IntProperty(name="Default Container", default=0)
|
||||||
|
should_include_children: BoolProperty(
|
||||||
|
name="Should Include Children", default=True, update=update_should_include_children
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def active_container(self):
|
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_OFF", text="")
|
||||||
row.operator("bim.select_decomposed_elements", icon="HIDE_ON", text="")
|
row.operator("bim.select_decomposed_elements", icon="HIDE_ON", text="")
|
||||||
row.operator("bim.select_container", icon="OBJECT_DATA", text="").container = ifc_definition_id
|
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 = row.operator("bim.delete_container", icon="X", text="")
|
||||||
op.container = ifc_definition_id
|
op.container = ifc_definition_id
|
||||||
|
|
||||||
@@ -157,13 +154,17 @@ class BIM_PT_spatial_decomposition(Panel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not self.props.total_elements:
|
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.label(text="No Contained Elements", icon="FILE_3D")
|
||||||
|
row.prop(self.props, "should_include_children", text="", icon="OUTLINER")
|
||||||
return
|
return
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=f"{self.props.total_elements} Contained Elements", icon="FILE_3D")
|
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(
|
self.layout.template_list(
|
||||||
"BIM_UL_elements",
|
"BIM_UL_elements",
|
||||||
|
|||||||
@@ -235,7 +235,13 @@ class Spatial(blenderbim.core.tool.Spatial):
|
|||||||
container = tool.Ifc.get().by_id(container.ifc_definition_id)
|
container = tool.Ifc.get().by_id(container.ifc_definition_id)
|
||||||
|
|
||||||
results = {}
|
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)
|
element_type = ifcopenshell.util.element.get_type(element)
|
||||||
ifc_class = element.is_a()
|
ifc_class = element.is_a()
|
||||||
type_name = element_type.Name or "Unnamed" if element_type else "Untyped"
|
type_name = element_type.Name or "Unnamed" if element_type else "Untyped"
|
||||||
|
|||||||
Reference in New Issue
Block a user