From cd458780e642b44b1a5a80d9b1c6dd26c54fc9ce Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Fri, 20 Mar 2026 19:00:47 -0500 Subject: [PATCH] Add ALT+Click unhide to select_by_material ALT+Click now unhides hidden objects (viewport and local hide) before selecting, matching the behavior added to other select operators. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/material/operator.py | 9 +++++++-- src/bonsai/bonsai/core/material.py | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/material/operator.py b/src/bonsai/bonsai/bim/module/material/operator.py index 7587a7e4ed..f4c983928e 100644 --- a/src/bonsai/bonsai/bim/module/material/operator.py +++ b/src/bonsai/bonsai/bim/module/material/operator.py @@ -61,13 +61,18 @@ class DisableEditingMaterials(bpy.types.Operator): class SelectByMaterial(bpy.types.Operator): bl_idname = "bim.select_by_material" bl_label = "Select By Material" - bl_description = "Select objects using the provided material" + bl_description = "Select objects using the provided material\n\nALT+Click to also unhide hidden objects (viewport and local hide)" bl_options = {"REGISTER", "UNDO"} material: bpy.props.IntProperty() + should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"}) + + def invoke(self, context, event): + self.should_unhide = event.alt + return self.execute(context) def execute(self, context): material = tool.Ifc.get().by_id(self.material) - core.select_by_material(tool.Material, tool.Spatial, material=material) + core.select_by_material(tool.Material, tool.Spatial, material=material, should_unhide=self.should_unhide) # copy selection query to clipboard if material.is_a("IfcMaterialLayerSet"): diff --git a/src/bonsai/bonsai/core/material.py b/src/bonsai/bonsai/core/material.py index 0a08f5e0bf..4aea28d93d 100644 --- a/src/bonsai/bonsai/core/material.py +++ b/src/bonsai/bonsai/core/material.py @@ -82,9 +82,12 @@ def disable_editing_materials(material: type[tool.Material]) -> None: def select_by_material( - material_tool: type[tool.Material], spatial: type[tool.Spatial], material: ifcopenshell.entity_instance + material_tool: type[tool.Material], + spatial: type[tool.Spatial], + material: ifcopenshell.entity_instance, + should_unhide: bool = False, ) -> None: - spatial.select_products(material_tool.get_elements_by_material(material)) + spatial.select_products(material_tool.get_elements_by_material(material), unhide=should_unhide) def enable_editing_material(material_tool: type[tool.Material], material: ifcopenshell.entity_instance) -> None: