Page MenuHome

Drivers are not re-linking data when duplicating objects
Closed, ArchivedPublic

Description

Duplicates: T31161

--- Operating System, Graphics card ---
RAM: 2GB
CPU: AMD Athlon X2 4800+
GFX: Nvidia GeForce 8400GS
Driver: 310.14
OS: LinuxMint 14 64 bits

--- Blender version with error ---
Blender 2.68a (r58536)

--- Short description of error ---
It just happens with some of them. Re-linking is working well with general purpose drivers, like those available for Loc, Rot, Scale, Modifiers or Constraints, but there are still some of them that get ignored when duplicating objects. Those are some inherent drivers that should be duplicated, like the value for Shapes in Meshes and Curves, or Extrusion and Offset for Curves.

Some drivers in which I've found this behaviour:
- Meshes: Shape Keys (Value, Min and Max Ranges)
- Curves: Shape Keys, Smooth (Twisting), Offset, Extrude, Depth, Resolution, Start-End Bevel Factor, Frames (Path Animation), Evaluation Time, Resolution
- Surfaces: Shape Keys, Order (U and V), Resolution (U and V)
- Metaballs: This isn't producing any driver at all. View, Render and Threshold aren't displaying in Drivers, in the Graph Editor, though is generating some empty Datablocks without Channels.
- Text: Everything on texts doesn't duplicate drivers. Exact same case as Curves.
- Lattices: Shape Keys. Drivers generated by Lattices aren't working for U, V and W values, even when they appear to be working in Graph Editor.
- Armatures: All parameters for Armature Object and Bones.
- Speakers: Like Metaballs, they do not generate any driver for Volume nor Pitch.
- Camera: Everything on cameras doesn't duplicate drivers.
- Lamps: Everything on lamps doesn't duplicate drivers.

--- Steps for others to reproduce the error (preferably based on attached .blend file) ---
In the attached .blend, I show you two examples of driver duplication. There are two cubes on top of camera's view. The left of them is the original, which have a Property named 'prop', who drives the Z scaling of the same Object, so I can control it's Z Scale from the Custom Property on Object Context or from 3DView. To it's right is the duplicated cube who inherited the original driver and then re-linked the data to the newly created object. That's why I can control their Z Scaling independently. This is how all should work.
Now, in the bottom of camera's view you'll see two deformed cubes. The left of them is the original. In this case, the object have a Shape Key named 'key 1' whose value is intended to be driven the same way as the example above. When we change the Property value it works ok, but when we duplicate the object (The deformed cube at right), it doesn't duplicate the drivers of the original cube, so when we want to drive the Shape Key for the second object using its own Property, it just does nothing, because one have to change the object data manually in the Graph Editor. By default, this behaviour makes the first Object's Property to drive both cubes at the same time, and this is very bad, specially with complex set-ups. So, everytime we need to duplicate an Object with Shape Keys, all data have to be manually re-linked along all its drivers.

If you want more details about the steps:
1) Create a Shape Key for default Cube (Basis)
2) Create a key 1, enter edit mode, move some vertices
3) Add a driver for key 1 "Value"
4) In Object Context and Custom Properties, add a new property (prop). Copy its value's data path
5) In Graph Editor > Drivers, select key 1 and make Averaged Value, Single Property, assign the same object who owns the Property (Cube) and paste the Propery path. Now the key 1 value should be driven by the Property.
6) Duplicate the object to the right and try to use its own Property to drive its Shape Key. Not possible, so you are forced to manually change that object in the Graph Editor (Cube.001). This should be automatically, as Loc, Rot, Scale drivers does.

Hope it helps, and sorry to extend so much about this topic.
Kind Regards.

Details

Type
To Do

Event Timeline

Here's what seems to be happening:

1. When duplicating an Object: BKE_object_relink is called, which in turn relinks the animdata *of the Object data block*. All drivers in this animdata will then be redirected to the duplicated data blocks, including the object itself as well as it's data (which is also duplicated).

2. Using a driver on a *different* data block like shape keys or the object data (mesh, lamp, etc.) will NOT be relinked, even if associated to the duplicated object and duplicated along with it.

There just seems to be no concept for relinking data blocks in general, this feature is limited to Object atm. Need to discuss if it's feasible to implement.

Duplicating Shape Keys drivers data when doing real duplications (Ctrl+D) would be the most logical thing. One more thing to remember is that Shape Keys aren't the only kind of per-object data that should de duplicated, at least from a user perspective. I understand this could be problematic in blender architecture, so take your time.

There is already a Todo item for this:
http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/Animation#Animation_System

This issue also occurs with objects linked in from File->Link. Both with duplicating the linked instance, and with linking in a new instance from File->Link