Active object is unchanged if operator started with temp_override #113966
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
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#113966
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?
If operator is started with temp_override and it's trying to change active object it wouldn't change the actual active object in the scene and wouldn't change the active object in the current context that's accessible from the operator.
What expected -
context.active_object
to change both during operator when active object was changed and after operator has finished.So, for example, if you
temp_override
and call operator that's calling another opreator and expecting it to change the active object, the operator will fail.How to reproduce:
temp_override
Code output:
I'm not sure what point is trying to be made here. In the 'after operator' case, the
active_object
is being retrieved from within thetemp_override
context manager that has specifically overriddenactive_object
with the "Cube", so the retrievedactive_object
is the "Cube" as I would have expected.Actually I would expect
after operator
to returnCamera
already and unsureafter context manager exit
. Maybe it's just me but I thoughttemp_override
to override the current context's variables whenwith
block started and then they are allowed to be changed during the execution.The main issue for me is that operator that's relying on changing active object during it's execution won't be executed correctly if it's started with
temp_override
sincecontext
seems to be kind of frozen while it's insidewith context.temp_override
block.If
Context
was a pure Python class, I would imagine it being similar to:Thank you for the detailed example, it makes sense now. I guess it's a limitation of the current context override design.
Now I'm thinking there is a workaround to get actual
active_object
if it was changed duringtemp_override
is bycontext.view_layer.objects.active
instead ofcontext.active_object
.I guess the current rules for writing operators
execute()
are:context.active_object
. If it's changed then you need to get it explicitly likecontext.view_layer.objects.active
.active_object
context
that was at beginning of operator Acontext.view_layer.objects.active = obj
Then you pass it to B with
context.temp_override
(likecontext.temp_override(active_object=cube)
) and not by changing item explicitly.Then called operator B won't break if operator A was called within another
context.temp_override
.That way operators will always work with and without
temp_override
.It seems this is working as intended as @Mysteryem explained. Though I'd ask @ideasman42 to have another look before closing.