bpy.ops.scene.new fails to set context when called from properties panel #43057
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#43057
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?
System Information
Windows 7 x64, GPU irrelevant
Blender Version
Broken: 2.73 53ec177
Worked: never?
Short description of error
bpy.ops.scene.new fails to set the context when called from the properties panel. Apparently users have been [struggling ]] with this for [ http://blenderartists.org/forum/showthread.php?204227-Select-Scene-from-Python | years .
Exact steps for others to reproduce the error
Blend file: bpy_ops_scene_new_bug.blend
Changed status to: 'Open'
Added subscriber: @MadMinstrel
Added subscribers: @ideasman42, @Sergey
@MadMinstrel, it is not recommended to use operators from other operators, especially if they're changing context. Using
bpy.data
is the way to go here.@ideasman42, i'm not sure if the case above is supposed to work, and also not sure why there's a difference depending on how the operator was invoked. What's your opinion here?
@Sergey In my particular case, I'm working on a baking addon. I have to prepare a scene before baking - merge/split objects, adjust UVs, modify shaders, run a compositor tree on the result once it's baked, etc. Lots of destructive stuff, which is why I'm doing it in a temporary scene. Since in the end I have to call bpy.ops.object.bake, and that relies on context, I don't think I can avoid setting it?
I'm not sure that this is supposed to work at all, but if not, it should at least generate an error, right? It'd be nice if it worked though. If it's not going to work, I'll have to move the bake button somewhere into the 3d View, and it sort of belongs in the Render tab.
This can probably be fixed, claiming.
Changed status from 'Open' to: 'Archived'
This is nearly the same bug as blender/blender#43976
The problem here is its not assured that the buttons context scene is matching the screen's scene.
In fact its possible to pin a scene and in that case you don't really want to use the pinned scene either.
So the fix is not to use the button context at all, use
INVOKE_SCREEN
/EXEC_SCREEN