Skip to content

Commit 873f9f0

Browse files
committed
Add ALT+Click unhide to select_similar_container
ALT+Click now unhides hidden objects (viewport and local hide) before selecting. Also fixes select_products to set hide_viewport in addition to hide_set when unhiding. Generated with the assistance of an AI coding tool.
1 parent ea27b4f commit 873f9f0

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,16 @@ def execute(self, context):
284284
class SelectSimilarContainer(bpy.types.Operator):
285285
bl_idname = "bim.select_similar_container"
286286
bl_label = "Select Similar Container"
287-
bl_description = "Recurvisevly selects all objects in the container.\n\nCtrl+click to select only one level deep"
287+
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)"
288288
bl_options = {"REGISTER", "UNDO"}
289289

290290
is_recursive: bpy.props.BoolProperty(default=True)
291+
should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
291292

292293
def invoke(self, context, event):
293294
if event.type == "LEFTMOUSE" and event.ctrl:
294295
self.is_recursive = False
296+
self.should_unhide = event.alt
295297
return self.execute(context)
296298

297299
def execute(self, context):
@@ -300,6 +302,7 @@ def execute(self, context):
300302
tool.Spatial,
301303
obj=context.active_object,
302304
is_recursive=self.is_recursive,
305+
should_unhide=self.should_unhide,
303306
)
304307
self.is_recursive = True # <-- forcibly reset
305308
return {"FINISHED"}

src/bonsai/bonsai/core/spatial.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,13 @@ def select_similar_container(
124124
spatial: type[tool.Spatial],
125125
obj: bpy.types.Object,
126126
is_recursive: bool = True,
127+
should_unhide: bool = False,
127128
) -> None:
128129
element = ifc.get_entity(obj)
129130
if element:
130-
spatial.select_products(spatial.get_decomposed_elements(spatial.get_container(element), is_recursive))
131+
spatial.select_products(
132+
spatial.get_decomposed_elements(spatial.get_container(element), is_recursive), unhide=should_unhide
133+
)
131134

132135

133136
def select_product(spatial: type[tool.Spatial], product: ifcopenshell.entity_instance) -> None:

src/bonsai/bonsai/tool/spatial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def select_products(cls, products: Iterable[ifcopenshell.entity_instance], unhid
200200
obj = tool.Ifc.get_object(product)
201201
if obj and view_layer.objects.get(obj.name):
202202
if unhide:
203+
obj.hide_viewport = False
203204
obj.hide_set(False)
204205
obj.select_set(True)
205206

0 commit comments

Comments
 (0)