mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
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:
@@ -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_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"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
container: bpy.props.IntProperty(default=0)
|
||||||
is_recursive: bpy.props.BoolProperty(default=True)
|
is_recursive: bpy.props.BoolProperty(default=True)
|
||||||
should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
|
should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
|
||||||
|
|
||||||
@@ -297,10 +298,17 @@ class SelectSimilarContainer(bpy.types.Operator):
|
|||||||
return self.execute(context)
|
return self.execute(context)
|
||||||
|
|
||||||
def execute(self, 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(
|
core.select_similar_container(
|
||||||
tool.Ifc,
|
|
||||||
tool.Spatial,
|
tool.Spatial,
|
||||||
obj=context.active_object,
|
container=container,
|
||||||
is_recursive=self.is_recursive,
|
is_recursive=self.is_recursive,
|
||||||
should_unhide=self.should_unhide,
|
should_unhide=self.should_unhide,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ class BIM_PT_spatial_decomposition(Panel):
|
|||||||
op = col.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default")
|
op = col.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default")
|
||||||
op.container = ifc_definition_id
|
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 = row.operator("bim.set_container_visibility", icon="FULLSCREEN_EXIT", text="")
|
||||||
op.mode = "ISOLATE"
|
op.mode = "ISOLATE"
|
||||||
op.container = ifc_definition_id
|
op.container = ifc_definition_id
|
||||||
@@ -152,7 +152,10 @@ class BIM_PT_spatial_decomposition(Panel):
|
|||||||
|
|
||||||
# The only operator that's enabled for IfcProject.
|
# The only operator that's enabled for IfcProject.
|
||||||
col = row.column(align=True)
|
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)
|
col = row.column(align=True)
|
||||||
op = col.operator("bim.delete_container", icon="X", text="")
|
op = col.operator("bim.delete_container", icon="X", text="")
|
||||||
|
|||||||
@@ -714,9 +714,9 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
description="Default parameters for BIM elements",
|
description="Default parameters for BIM elements",
|
||||||
)
|
)
|
||||||
|
|
||||||
container_hide_show_isolate: BoolProperty(
|
show_container_tools: BoolProperty(
|
||||||
name="Container hide/show/isolate",
|
name="Show Container Tools (Select, Hide, Show, Isolate)",
|
||||||
description="Enable container hide/show/isolate feature in the UI",
|
description="Enable container select, hide/show/isolate tools in the UI",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -786,7 +786,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
pset_dir: str
|
pset_dir: str
|
||||||
doc: DocPreferences
|
doc: DocPreferences
|
||||||
default_parameters: DefaultParameters
|
default_parameters: DefaultParameters
|
||||||
container_hide_show_isolate: bool
|
show_container_tools: bool
|
||||||
chain_filter_with_set_operations: bool
|
chain_filter_with_set_operations: bool
|
||||||
save_metadata_blend_file: bool
|
save_metadata_blend_file: bool
|
||||||
metadata_blend_file_suffix: str
|
metadata_blend_file_suffix: str
|
||||||
@@ -984,7 +984,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
layout.prop(self, "bsdd_baseurl")
|
layout.prop(self, "bsdd_baseurl")
|
||||||
|
|
||||||
def draw_extras_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
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 = layout.row(align=True)
|
||||||
row.prop(self, "chain_filter_with_set_operations")
|
row.prop(self, "chain_filter_with_set_operations")
|
||||||
row.operator("bim.open_uri", text="", icon="HELP").uri = "https://community.osarch.org/discussion/3270"
|
row.operator("bim.open_uri", text="", icon="HELP").uri = "https://community.osarch.org/discussion/3270"
|
||||||
|
|||||||
@@ -120,17 +120,12 @@ def select_container(
|
|||||||
|
|
||||||
|
|
||||||
def select_similar_container(
|
def select_similar_container(
|
||||||
ifc: type[tool.Ifc],
|
|
||||||
spatial: type[tool.Spatial],
|
spatial: type[tool.Spatial],
|
||||||
obj: bpy.types.Object,
|
container: ifcopenshell.entity_instance,
|
||||||
is_recursive: bool = True,
|
is_recursive: bool = True,
|
||||||
should_unhide: bool = False,
|
should_unhide: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
element = ifc.get_entity(obj)
|
spatial.select_products(spatial.get_decomposed_elements(container, is_recursive), unhide=should_unhide)
|
||||||
if element:
|
|
||||||
spatial.select_products(
|
|
||||||
spatial.get_decomposed_elements(spatial.get_container(element), is_recursive), unhide=should_unhide
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def select_product(spatial: type[tool.Spatial], product: ifcopenshell.entity_instance) -> None:
|
def select_product(spatial: type[tool.Spatial], product: ifcopenshell.entity_instance) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user