Compare commits

...

1 Commits

Author SHA1 Message Date
Petru Conduraru 2988696161 Bonsai: keep "disable selection" objects visible when activating a drawing (#7681)
tool.Blender.isolate_objects keeps objects visible by selecting the
intended set and then hiding everything unselected via
hide_view_set(unselected=True). Blender refuses to select an object whose
"disable selection" (hide_select) is enabled, so such an object is treated
as unselected and hidden. Activating a drawing therefore turned off any
object that had disable-selection on.

Temporarily clear hide_select on the target objects so they can be
selected (and thus kept visible), then restore it. The clear/restore is
wrapped in try/finally so hide_select is always restored even if the hide
operator raises.

Verified in headless Blender with real objects: an object with
hide_select set is hidden by the pre-fix logic and stays visible with the
fix, hide_select is preserved, and unrelated objects are still hidden.

Generated with the assistance of an AI coding tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 08:29:56 +03:00
+17 -4
View File
@@ -2315,10 +2315,23 @@ class Blender(bonsai.core.tool.Blender):
bpy.ops.object.hide_view_clear(select=False)
bpy.ops.object.select_all(action="DESELECT")
for obj in objs:
obj.select_set(True)
with bpy.context.temp_override(**override):
bpy.ops.object.hide_view_set(unselected=True)
# Objects with "disable selection" (hide_select) enabled cannot be
# selected, so they would be treated as unselected and hidden by
# hide_view_set(unselected=True) below - see #7681. Temporarily clear
# hide_select so they can be selected (and thus kept visible), then
# restore it afterwards.
unselectable = []
try:
for obj in objs:
if obj.hide_select:
obj.hide_select = False
unselectable.append(obj)
obj.select_set(True)
with bpy.context.temp_override(**override):
bpy.ops.object.hide_view_set(unselected=True)
finally:
for obj in unselectable:
obj.hide_select = True
bpy.ops.object.select_all(action="DESELECT")
for name in previously_selected: