Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return to global view before closing a window #80

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion client/ayon_blender/api/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def capture(
},
}


def isolate_objects(window, objects):
"""Isolate selection"""
deselect_all()
Expand All @@ -133,7 +132,22 @@ def isolate_objects(window, objects):

deselect_all()

def restore_global_view(window):
"""Exit local view if active.

Blender currently does not exit localview when closing windows.
"""

types = {"MESH", "GPENCIL"}
objects = [obj for obj in window.scene.objects if obj.type in types]

context = create_blender_context(selected=objects, window=window)

with bpy.context.temp_override(**context):
# Only toggle back if in local view
if bpy.context.space_data.local_view:
bpy.ops.view3d.localview()

def _apply_options(entity, options):
for option, value in options.items():
if isinstance(value, dict):
Expand Down Expand Up @@ -279,4 +293,6 @@ def _independent_window():
try:
yield window
finally:
restore_global_view(window)
bpy.ops.wm.window_close()