Page MenuHome

Shape key users not properly mapped when duplicating an object & mesh
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows 10
Graphics card: <irrelevant>

Blender Version
Broken: 2.80 - 2.82
Worked: 2.79

Short description of error

Shape key users do not get properly mapped when duplicating an object & mesh via the python interface

Exact steps for others to reproduce the error

  1. Open the default startup
  2. Run the following script:
import bpy

# get the default cube
obj = bpy.data.objects["Cube"]

# add a shape key
obj.shape_key_add()

# get the new key block
kb = obj.data.shape_keys.key_blocks[0]

# print the mesh and shape key user (should match)
print()
print("Before copy:")
print(obj.data.name)
print(kb.id_data.user.name)

# duplicate the object and the object's mesh
obj_dup = obj.copy()
obj_dup.data = obj.data.copy()
obj_dup.name = "duplicate_obj"
obj_dup.data.name = "duplicate mesh"

# get the key block again, from the duplicated mesh
kb_dup = obj_dup.data.shape_keys.key_blocks[0]

# print the duplicated mesh and shape key user (should match)
print()
print("After copy:")
print(obj_dup.data.name)
print(kb_dup.id_data.user.name)

Event Timeline

When the blend file is saved and restarted, the following prints to the Command Line:

Error: ID MEduplicate mesh uses shapekey KEKey.001, but its 'from' pointer is invalid (0000017945F54248), fixing...

Once the invalid pointer is fixed by this automatic cleanup, the shape keys work fine.

Richard Antalik (ISS) changed the task status from Needs Triage to Confirmed.Mon, Feb 17, 8:55 AM
Richard Antalik (ISS) added a project: Python.
Bastien Montagne (mont29) changed the subtype of this task from "Report" to "Bug".
Bastien Montagne (mont29) edited projects, added Data, Assets & I/O; removed Python.