Wrong object naming when using context.copy #106105

Open
opened 2023-03-24 13:49:32 +01:00 by Vincent · 8 comments

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.29

Blender Version
Broken: version: 2.93, 3.6, 4.0
Worked: none

Short description of error
When duplicating an object with a parent and using context.copy() with the object.duplicate or any other operator that uses object.duplicate the child object to get a wrong name.

Exact steps for others to reproduce the error

  1. set one object as a parent of another
  2. select both objects (parent and child)
  3. run this code in the Text Editor
  4. now take a look in the outline the duplicated parent is selected, but the origin child is also selected and the name of the origin child has changed
import bpy
bpy.ops.object.duplicate_move(bpy.context.copy())

import bpy

with bpy.context.temp_override(**bpy.context.copy()):
    bpy.ops.object.duplicate_move()
Before After
image image
**System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.29 **Blender Version** Broken: version: 2.93, 3.6, 4.0 Worked: none **Short description of error** When duplicating an object with a parent and using context.copy() with the object.duplicate or any other operator that uses object.duplicate the child object to get a wrong name. **Exact steps for others to reproduce the error** 1. set one object as a parent of another 2. select both objects (parent and child) 3. run this code in the Text Editor 4. now take a look in the outline the duplicated parent is selected, but the origin child is also selected and the name of the origin child has changed ``` import bpy bpy.ops.object.duplicate_move(bpy.context.copy()) ``` - - - ``` import bpy with bpy.context.temp_override(**bpy.context.copy()): bpy.ops.object.duplicate_move() ``` | Before | After | | -------- | -------- | | ![image](/attachments/c77f8487-c0e5-42d1-9a3b-d5501459c19c) | ![image](/attachments/6589eeea-9229-433f-b365-aa2bc2e19861) |
Vincent added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-03-24 13:49:32 +01:00
<blender_console>:1: DeprecationWarning: Passing in context overrides is deprecated in favor of Context.temp_override(..), calling "object.duplicate_move"
```py <blender_console>:1: DeprecationWarning: Passing in context overrides is deprecated in favor of Context.temp_override(..), calling "object.duplicate_move" ```
Iliya Katushenock added the
Interest
Python API
label 2023-03-24 14:38:46 +01:00
Author

Thanks, but Blender 2.93 is supported until June 2023 and does not support temp_override(), so I made a report

Note: The Problem does not occur with temp_override()

Thanks, but Blender 2.93 is supported until June 2023 and does not support `temp_override()`, so I made a report **Note**: The Problem does **not** occur with `temp_override()`
Member

Can confirm. Though not sure whether this will be fixed in 2.93

Can confirm. Though not sure whether this will be fixed in 2.93
Pratik Borhade added
Module
Python API
Status
Confirmed
and removed
Status
Needs Triage
Interest
Python API
labels 2023-03-28 08:18:06 +02:00
Pratik Borhade added this to the 2.93 LTS milestone 2023-03-28 08:18:15 +02:00
Brecht Van Lommel added the
Interest
Core
label 2023-05-01 17:07:27 +02:00
Member

2.93 will not see another release, not sure though if we should close this now, since deprecated does not necessarily mean we dont accept bug reports for this (or maybe it does, will ask around)?

2.93 will not see another release, not sure though if we should close this now, since deprecated does not necessarily mean we dont accept bug reports for this (or maybe it does, will ask around)?
Member

If I do the Context.temp_override equivalent of overriding everything in the dict created by bpy.context.copy() then I get the same odd renaming behaviour (using 4.0.0a 2023-06-03 ab6860f3de0f):

import bpy

with bpy.context.temp_override(**bpy.context.copy()):
    bpy.ops.object.duplicate_move()

Edit: It looks like all that's needed is to override selected_editable_objects with whatever its current value is:

import bpy

with bpy.context.temp_override(selected_editable_objects=bpy.context.selected_editable_objects):
    bpy.ops.object.duplicate()
If I do the `Context.temp_override` equivalent of overriding everything in the `dict` created by `bpy.context.copy()` then I get the same odd renaming behaviour (using 4.0.0a 2023-06-03 `ab6860f3de0f`): ```py import bpy with bpy.context.temp_override(**bpy.context.copy()): bpy.ops.object.duplicate_move() ``` Edit: It looks like all that's needed is to override `selected_editable_objects` with whatever its current value is: ```py import bpy with bpy.context.temp_override(selected_editable_objects=bpy.context.selected_editable_objects): bpy.ops.object.duplicate() ```
Member

In newer version (4.0), context argument for operator call is removed: ac263a9bce

Use of temp_override is recommended and 3.3LTS supports it. So I think we can close this report.

If I do the Context.temp_override equivalent of overriding everything in the dict created by bpy.context.copy() then I get the same odd renaming behaviour

Maybe we can open a separate report for it?

In newer version (4.0), context argument for operator call is removed: ac263a9bce53e190d07d679a058a230e91e722be Use of `temp_override` is recommended and 3.3LTS supports it. So I think we can close this report. > If I do the `Context.temp_override` equivalent of overriding everything in the `dict` created by `bpy.context.copy()` then I get the same odd renaming behaviour Maybe we can open a separate report for it?
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2023-07-31 12:05:29 +02:00
Member

I'm not really sure this needs to be closed, the report was that using an override with context.copy() causes unexpected behaviour, which is the case with both the deprecated context override argument and temp_override. The reporter's claim that the problem did not occur with temp_override was incorrect.

If I were to open a new report it would be identical aside from the sample code would use temp_override with context.copy() instead of the override argument (or just overriding selected_editable_objects since I tracked that down as the cause).

I'm not really sure this needs to be closed, the report was that using an override with `context.copy()` causes unexpected behaviour, which is the case with both the deprecated context override argument and `temp_override`. The reporter's claim that the problem did not occur with `temp_override` was incorrect. If I were to open a new report it would be identical aside from the sample code would use `temp_override` with `context.copy()` instead of the override argument (or just overriding `selected_editable_objects` since I tracked that down as the cause).
Member

discussion and original report was quite misleading than the actual problem (which you've found), hence closed :)
Anyways, we can reopen the report with few edits.

discussion and original report was quite misleading than the actual problem (which you've found), hence closed :) Anyways, we can reopen the report with few edits.
Pratik Borhade changed title from operator object.duplicate wrong object naming when object has parent and using context.copy to Wrong object naming when using context.copy 2023-08-01 10:51:27 +02:00
Blender Bot added
Status
Needs Triage
and removed
Status
Archived
labels 2023-08-01 10:53:35 +02:00
Pratik Borhade removed this from the 2.93 LTS milestone 2023-08-01 10:53:39 +02:00
Pratik Borhade added
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-08-01 10:53:46 +02:00
Sign in to join this conversation.
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
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106105
No description provided.