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

Export changes the window's scene to the context's active scene. #1961

Open
vfig opened this issue Aug 1, 2023 · 1 comment · May be fixed by #2133
Open

Export changes the window's scene to the context's active scene. #1961

vfig opened this issue Aug 1, 2023 · 1 comment · May be fixed by #2133
Labels
enhancement New feature or request

Comments

@vfig
Copy link

vfig commented Aug 1, 2023

Context: I am using python to automate exporting a number of GLTF files from various objects stored in different scenes in my .blend file. For each of the exports, my code uses context.temp_override(scene=...) to make the appropriate scene active, then invokes bpy.ops.export_scene.gltf(use_active_scene=True, ...).

After invoking bpy.ops.export_scene.gltf(), the currently active scene in the UI is changed to the scene that I passed into temp_override(). This is particularly annoying when I am in a workspace with a pinned scene, as the export changes which scene is pinned.

This seems to be due to: gltf2_blender_gather.py lines 36-48:

    store_user_scene = bpy.context.scene
...
    # restore user scene
    bpy.context.window.scene = store_user_scene

Ideally the GLTF export ought to be using temp_override() itself instead of changing the context. But at least to ensure the export restores the same scene as was in the window beforehand, line 36 ought to be:

    store_user_scene = bpy.context.window.scene
@julienduroure
Copy link
Collaborator

Hello,
Let's do it in 2 times:

  • First, change export as you suggested on line 36
  • Investigate & regression checks if we can use temp_override()

This can also be fixed in collaboration with #1943 & #1073 to better handle context & depsgraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants