When switching scenes using "-S" argument in command line, scripts called by "--python-text" do not get correct scene context #55991
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#55991
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version: 2.79b (linux 64)
active_scene_api.blend
How to reproduce:
blender -b active_scene_api.blend --python-text "active_scene.py"
blender -b active_scene_api.blend -S "Scene B" --python-text "active_scene.py"
This can cause errors and unexpected behavior with render scripts.
Added subscriber: @rocketman
Added subscribers: @ideasman42, @mont29
Took me some time to understand what is happening here… thing is, we do some backup/sanitizing of context before executing py scripts, and among other things,
arg_py_context_backup
callsCTX_wm_window_set
, which sets again context's Scene from active windows' screen scene…@ideasman42 think you are familiar with this area of the code, not sure what is the best/correct solution here. :/
Thank you @mont29 . I did discover a workaround which was to wrap the script in a function that is appended to the app handlers. Consider the following script:
When called from bpy.app.handlers. render_init, the context is correct. Perhaps this is a better way to do it anyway, but as a matter of principle it still seems better to make sure that the context is consistent, and called from something other than the active window screen screen, since the screen isn't always there!
This issue was referenced by blender/blender@3e2dfc6db8
Changed status from 'Open' to: 'Resolved'