Page MenuHome

copying armature and mesh with shapekey drivers (to bone) doesn't change driver variables
Closed, ResolvedPublic

Description

System Information
GNU/Linux (Fedora 23) Intel and Nvidia GFX/ Intel CPU

Blender Version
Broken: Current Git
Worked: Probably never

Short description of error
If I have a simple rig - a mesh and armature - where the armature is driving mesh shapekeys, and I copy both, I'd expect the copy to be self-contained - i.e.the drivers on the copied mesh should reference the copied armature, instead, they remain tied to the original. I use python loops to fix this, but it would be painful otherwise

Exact steps for others to reproduce the error
First download the attached .blend.

- it's very simple, only two objects, no python needed.
1- Open the file
2- Observe that Suzanne has a single shapekey with a driver based on Bone X-location - you could ctrl-tab the rig into pose mode and move the bone on the X axis if you want to see the effect
3- select both suzanne and armature (make sure it is in object mode) and shift D
4- now Suzanne.001 also has drivers! unfortunately they refer to Armature, not Armature.001

NOTE: If I didn't copy the armature I would fully expect and want the behavior above - but it's fair to say when copying a rig, the vast majority of times, we would want the drivers to 'remap' and the new rig to be self-contained.

Cheers,
Bassam

Event Timeline

bassam kurdali (bassamk) updated the task description. (Show Details)
bassam kurdali (bassamk) raised the priority of this task from to Needs Triage by Developer.
bassam kurdali (bassamk) set Type to Bug.

Problem here is the limited support for ID remapping on duplication. This is not an inherent part of copying some data, but rather an additional "service" of the operator to make life easier for artists. None of the remapping works automatic, it has to be done explicitly. This feature is currently limited to the Object datablock itself and does not include any attached data, like the Mesh or its associated Key (shapekey) datablock.

Here is where the Object data is remapped:
https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/object/object_add.c$2193

Note that none of the code inside this function deals with Mesh or Key data. I'm not sure if this is possible to support in a meaningful way (where to draw the line? it has to take into account all the potential data dependencies ... arguably shapekeys are important enough to make an exception perhaps).

For a slightly simpler example code-wise: try making a driver for the "auto smooth" property on the mesh. This is not part of the shapekey but just of the Mesh datablock, but has the same problem: references here don't get remapped on duplication.

I have an addon that works around this problem; perhaps I should polish up and submit to blender's addons? currently it has the following issues:

1- only works if the objects are in a group
2- has a very specific naming convention (adds _nn) to group name and object names
3- might fail on corner cases

I seem to remember from a chat on irc with joshua that this kind of stuff should 'just work' from a user perspective - but perhaps he was alluding only to object level stuff.

There was an addon written a while back to solve this kinda problem.
http://blenderartists.org/forum/showthread.php?356354-Addon-replace-driver-targets

Its not as automated, but maybe its useful.
It works by replacing the objects the driver targets use.

That's a good idea (I usually have been dropping in console and looping over my object's drivers, replacing the ids)
A smart copy addon might also be nice, however the worry is people will encounter the problem but not understand why it's happening... better than nothing tho.