mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
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>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user