Add container tools to spatial decomposition panel

- Add bim.select_similar_container button to the spatial
  decomposition panel, gated behind the new
  show_container_tools preference (renamed from
  container_hide_show_isolate)
- Fix select_similar_container to resolve container from
  the active list item rather than the active object
- Unhide individual objects when showing container
  visibility (set_container_visibility SHOW/ISOLATE)

Generated with the assistance of an AI coding tool.
This commit is contained in:
Ryan Schultz
2026-03-20 20:06:53 -05:00
parent e3d5e1d1fe
commit 2ad30a00d7
4 changed files with 22 additions and 16 deletions
@@ -287,6 +287,7 @@ class SelectSimilarContainer(bpy.types.Operator):
bl_description = "Recursively selects all objects in the container.\n\nCtrl+click to select only one level deep\nAlt+click to also unhide hidden objects (viewport and local hide)"
bl_options = {"REGISTER", "UNDO"}
container: bpy.props.IntProperty(default=0)
is_recursive: bpy.props.BoolProperty(default=True)
should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
@@ -297,10 +298,17 @@ class SelectSimilarContainer(bpy.types.Operator):
return self.execute(context)
def execute(self, context):
if self.container:
container = tool.Ifc.get().by_id(self.container)
elif element := tool.Ifc.get_entity(context.active_object):
container = ifcopenshell.util.element.get_container(element)
else:
return {"CANCELLED"}
if not container:
return {"CANCELLED"}
core.select_similar_container(
tool.Ifc,
tool.Spatial,
obj=context.active_object,
container=container,
is_recursive=self.is_recursive,
should_unhide=self.should_unhide,
)
+5 -2
View File
@@ -139,7 +139,7 @@ class BIM_PT_spatial_decomposition(Panel):
op = col.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default")
op.container = ifc_definition_id
if tool.Blender.get_addon_preferences().container_hide_show_isolate:
if tool.Blender.get_addon_preferences().show_container_tools:
op = row.operator("bim.set_container_visibility", icon="FULLSCREEN_EXIT", text="")
op.mode = "ISOLATE"
op.container = ifc_definition_id
@@ -152,7 +152,10 @@ class BIM_PT_spatial_decomposition(Panel):
# The only operator that's enabled for IfcProject.
col = row.column(align=True)
col.operator("bim.select_container", icon="OBJECT_DATA", text="").container = ifc_definition_id
row_ = col.row(align=True)
row_.operator("bim.select_container", icon="OBJECT_DATA", text="").container = ifc_definition_id
if tool.Blender.get_addon_preferences().show_container_tools:
row_.operator("bim.select_similar_container", icon="RESTRICT_SELECT_OFF", text="").container = ifc_definition_id
col = row.column(align=True)
op = col.operator("bim.delete_container", icon="X", text="")
+5 -5
View File
@@ -714,9 +714,9 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
description="Default parameters for BIM elements",
)
container_hide_show_isolate: BoolProperty(
name="Container hide/show/isolate",
description="Enable container hide/show/isolate feature in the UI",
show_container_tools: BoolProperty(
name="Show Container Tools (Select, Hide, Show, Isolate)",
description="Enable container select, hide/show/isolate tools in the UI",
default=False,
)
@@ -786,7 +786,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
pset_dir: str
doc: DocPreferences
default_parameters: DefaultParameters
container_hide_show_isolate: bool
show_container_tools: bool
chain_filter_with_set_operations: bool
save_metadata_blend_file: bool
metadata_blend_file_suffix: str
@@ -984,7 +984,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
layout.prop(self, "bsdd_baseurl")
def draw_extras_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
layout.prop(self, "container_hide_show_isolate")
layout.prop(self, "show_container_tools")
row = layout.row(align=True)
row.prop(self, "chain_filter_with_set_operations")
row.operator("bim.open_uri", text="", icon="HELP").uri = "https://community.osarch.org/discussion/3270"
+2 -7
View File
@@ -120,17 +120,12 @@ def select_container(
def select_similar_container(
ifc: type[tool.Ifc],
spatial: type[tool.Spatial],
obj: bpy.types.Object,
container: ifcopenshell.entity_instance,
is_recursive: bool = True,
should_unhide: bool = False,
) -> None:
element = ifc.get_entity(obj)
if element:
spatial.select_products(
spatial.get_decomposed_elements(spatial.get_container(element), is_recursive), unhide=should_unhide
)
spatial.select_products(spatial.get_decomposed_elements(container, is_recursive), unhide=should_unhide)
def select_product(spatial: type[tool.Spatial], product: ifcopenshell.entity_instance) -> None: