Modifying multiple drivers variables easily

Hi,
I’m trying to transfer an object (it’s clothes) from an initial armature to a new one (both armature are identical, same bones). After doing that the object doesn’t follow the new armature properly (but all the weights are similar), it’s because of the drivers in the shape keys, they’re still attached to the initial armature. My problem is to point them to the new one.
Is there a way to change all the drivers Object ID, instead of doing it 1 by 1 ?
I think the picture will make my question clear
Thanks a lot !

You can do this in the Python console pretty quickly. Select the object and try this code:

for d in bpy.context.object.data.shape_keys.animation_data.drivers:
    d.driver.variables[0].targets[0].id = D.objects['NEW NAME HERE']

That should get most of them

Hi Rocketman,
thank you so much, you saved my time !
Works great

1 Like

Honestly I’m amazed that actually worked.

After few tries it worked without modifying your code at all, just replacing the name of the armature of course