From cc1b4a06e4c649e4b07c6ed67e9047102bc10c52 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sun, 19 Apr 2026 12:18:33 -0500 Subject: [PATCH] Fix #7969: Preserve local view on aggregate mode exit If local view was already active when aggregate mode was entered, disable_aggregate_mode no longer toggles it off. The pre-existing state is saved in was_in_local_view on BIMAggregateProperties and only cleared if local view was entered after aggregate mode began. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/aggregate/prop.py | 5 +++++ src/bonsai/bonsai/tool/aggregate.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/module/aggregate/prop.py b/src/bonsai/bonsai/bim/module/aggregate/prop.py index 424f2b829f..c3a3a16701 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/prop.py +++ b/src/bonsai/bonsai/bim/module/aggregate/prop.py @@ -148,6 +148,10 @@ class BIMAggregateProperties(PropertyGroup): name="True if it was previously in aggregate mode", default=False, ) + was_in_local_view: BoolProperty( + name="Was In Local View", + default=False, + ) if TYPE_CHECKING: in_aggregate_mode: bool @@ -157,3 +161,4 @@ class BIMAggregateProperties(PropertyGroup): not_editing_objects: bpy.types.bpy_prop_collection_idprop[Objects] aggregate_decorator: bool previous_state: bool + was_in_local_view: bool diff --git a/src/bonsai/bonsai/tool/aggregate.py b/src/bonsai/bonsai/tool/aggregate.py index 1f7f601862..92fd7b8f5d 100644 --- a/src/bonsai/bonsai/tool/aggregate.py +++ b/src/bonsai/bonsai/tool/aggregate.py @@ -202,6 +202,7 @@ class Aggregate(bonsai.core.tool.Aggregate): editing_obj = props.editing_objects.add() editing_obj.obj = obj.original + props.was_in_local_view = bool(context.space_data and context.space_data.local_view) props.in_aggregate_mode = True return {"FINISHED"} @@ -219,8 +220,9 @@ class Aggregate(bonsai.core.tool.Aggregate): if not element: continue - if context.space_data.local_view: + if context.space_data.local_view and not props.was_in_local_view: bpy.ops.view3d.localview() + props.was_in_local_view = False props.in_aggregate_mode = False props.not_editing_objects.clear()