bpy.context.scene incorrect information #71542
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#71542
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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
Operating system: Ubuntu 18.04.3 LTS
Blender Version
Broken: blender-2.80-linux-glibc217-x86_64
Broken: blender-2.81-125257758007-linux-glibc217-x86_64
Short description of error
I discovered this issue when testing with the Blender API in 2.80 but I could reproduce it in 2.81:
It seems that when you trigger a custom operator from a custom "panel button",
bpy.context.scene
will not update correctly after an immediate scene change by settingbpy.context.window.scene
. Although I noticed that if you call the operator directly, for example by searching in the search window, it works just fine.Code in the operator:
context.window.scene = scene
print(context.scene.name)```
Added subscriber: @mikewazowski11
Added subscriber: @lemenicier_julien
Added subscriber: @mont29
Changed status from 'Open' to: 'Archived'
Yep, you need to ensure update is effective then, see https://docs.blender.org/api/current/info_gotcha.html#stale-data
We do not handle user support on this tracker, only bug reports. User forums like blenderartists.org or blender.stackexchange.com and our devtalk should be used for that matter.
Ok thanks, I will keep that gotchas' page in mind, and ask before in those pages when possible.
@mont29 I tested it but it seems that even with bpy.context.view_layer.update() the wrong behavior can still be reproduced, am I missing something? Also I don't understand why it works when the operator is called directly with and without the manual update and when called from a panel it doesn't.
Changed status from 'Archived' to: 'Open'
Added subscriber: @ideasman42
The issue is related to the specific context of the Properties editor. If you add the panel to e.g. 3D view it works as expected, and if you call the operator from the Properties window it also fails.
Issue is that Properties space has its own 'current scene' storage, which is returned from its context, and that gets updated on UI update, not on depsgraph update (as is the case for 'normal' context from other spaces).
@ideasman42 would not consider this a bug, more like some internal limitation?
@mont29 So basically the solution is to move the panel out of the Properties editor or write a modal (timer event perhaps?) according to the docs... Any chance of having a way to manually force to update the depsgraph info for Properties editor in the future without resorting to the https://docs.blender.org/api/current/info_gotcha.html#can-i-redraw-during-the-script hack?
The issue here is not the depsgraph update (which is done through the
view_layer.update()
call), but the UI update (specifically the Properties editor update), for which afaik we have no direct way to trigger from python…Added subscriber: @Jeroen-Bakker
Changed status from 'Confirmed' to: 'Archived'
This issue seems like a feature request. The system works as intended, but there are limitations what needs development.