Skip to content

Commit cd45878

Browse files
committed
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.
1 parent 873f9f0 commit cd45878

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/bonsai/bonsai/bim/module/material/operator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ def execute(self, context):
6161
class SelectByMaterial(bpy.types.Operator):
6262
bl_idname = "bim.select_by_material"
6363
bl_label = "Select By Material"
64-
bl_description = "Select objects using the provided material"
64+
bl_description = "Select objects using the provided material\n\nALT+Click to also unhide hidden objects (viewport and local hide)"
6565
bl_options = {"REGISTER", "UNDO"}
6666
material: bpy.props.IntProperty()
67+
should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
68+
69+
def invoke(self, context, event):
70+
self.should_unhide = event.alt
71+
return self.execute(context)
6772

6873
def execute(self, context):
6974
material = tool.Ifc.get().by_id(self.material)
70-
core.select_by_material(tool.Material, tool.Spatial, material=material)
75+
core.select_by_material(tool.Material, tool.Spatial, material=material, should_unhide=self.should_unhide)
7176

7277
# copy selection query to clipboard
7378
if material.is_a("IfcMaterialLayerSet"):

src/bonsai/bonsai/core/material.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ def disable_editing_materials(material: type[tool.Material]) -> None:
8282

8383

8484
def select_by_material(
85-
material_tool: type[tool.Material], spatial: type[tool.Spatial], material: ifcopenshell.entity_instance
85+
material_tool: type[tool.Material],
86+
spatial: type[tool.Spatial],
87+
material: ifcopenshell.entity_instance,
88+
should_unhide: bool = False,
8689
) -> None:
87-
spatial.select_products(material_tool.get_elements_by_material(material))
90+
spatial.select_products(material_tool.get_elements_by_material(material), unhide=should_unhide)
8891

8992

9093
def enable_editing_material(material_tool: type[tool.Material], material: ifcopenshell.entity_instance) -> None:

0 commit comments

Comments
 (0)