# Is there a way to copy the drivers of the active object

Is there a way for selected objects to copy (or link) the drivers of the active object? with Ctrl+L we can copy many properties from active to selected, including object data, material, modifiers...etc. But I don't seem to find a way to copy driver.
To provide more explanation, I'm creating a motion-graphics file, where the scale of spheres is linked with drivers on 3 axes to the distance between the spheres and an empty controller.

I made one sphere to begin with, added the drivers, assigned the expression (var/10) in this case, then copied the sphere an x amount of times as you can see. now let's say I need to experiment with the expression, make it (var**2) for instance, or change the f-curve easing, I can do that to one sphere, no problem, my question is, is there a way to apply these changes to the drivers of all the spheres, without doing it manually one by one?
Please check the attached file (Blender 2.8 file):

• docs.blender.org/manual/en/latest/animation/drivers/… – FFeller Apr 10 at 17:45
• @FFeller I'm afraid that doesn't provide an answer, that's about manual copy paste, I'm asking about copying from active to selected object(s) that could be thousands of objects, as I mentioned in my question, this is doable for modifiers and many other stuff using ctrl+L – Georges Apr 10 at 17:58
• Select Animation Data from CTRL-L and I am curious why it didn't work for you? – Serge L Apr 10 at 22:23
• @Serge L, I tried this already, didn't work for me, but I see what you mean, this might work for other cases, where the variable is set to something else other than distance, but in my case, the active sphere as a distance variable becomes the same for all spheres. But anyways, I believe for many cases your answer is rigth, please put it as an answer and I will accept it, I'll post another answer later if I find a solution to my specific case, thank you. – Georges Apr 11 at 10:01

## 1 Answer

The answer is Ctrl + L then choose Animation Data, as "Serge L" mentioned in his comment, however there are limitations in my specific case, or whenever Distance is used as a factor.
The limitation is, when you duplicate an object that has drivers, Blender is smart enough to know, if the object itself is a factor in the distance, that the name of the duplicate object is to be used as a factor, this, unfortunately, doesn't happen when you copy Animation Data from one object to another, check the images below for explanation on what I mean.
While when copying Animation Data, it doesn't amend the object in distance factor in the driver

So in the case where a distance between two objects is the factor in the driver, there don't seem to be a solution, but in other cases where a simple location factor is used, copying animation data is the answer.
Aside from that, in order to find a solution for my case, I discarded the use of drivers, I coded a script instead to do that, here it is :

import bpy
###Parameters
#Change these parameters
#the following target_name variable
#will target all objects in scene that
#have "Cube" in there name
#factor is devision factor based on distance from active object "controller"
#when you run the script, register should be checked here in text editor
#and the controller should be the active object
#the script will run on each frame change

target_name = "Cube"
factor = 20

###End parameters

starting_frame = bpy.context.scene.frame_current
target_list =[]
act = bpy.context.object

#Populate a list of targets based on name
for t in bpy.context.scene.objects:
if target_name in t.name:
target_list.append(t)

def run_script(scene):
global starting_frame
print("-------------------------")
run_frame = bpy.context.scene.frame_current
print(run_frame)
for target in target_list:
distance_v = act.location-target.location
distance = pithag(act.location,target.location)
print(distance)
if run_frame != starting_frame:
target.scale.x = distance/factor
target.scale.y = distance/factor
target.scale.z = distance/factor
starting_frame = run_frame
print(starting_frame)

#Calcualte linear distance between target an controller "active object"
#Both arguments should be 3D vector
def pithag(vec1, vec2):
dist = ((vec1[0]-vec2[0])**2) + ((vec1[1]-vec2[1])**2) + ((vec1[2]-vec2[2])**2)
return dist

#Script will run on frame change
bpy.app.handlers.frame_change_pre.append(run_script)


And here's a GIF of the result, the diference is, here I can edit the variables in the script, and it'll apply to all targeted objects

NOTE: In order to stop the targets from getting very large when the distance is great, I added Limit Scale constraint to the targets.

• At first I was thinking you would iterate all cubes to change object inside driver, but you did whole job inside script!. I am wondering why you didn't use "Animation Nodes" for such task? – Serge L Apr 11 at 20:57
• I fiddled with animation nodes few months ago, it's an awesome addon, that I decided not to use it for the time being for 3 reasons, 1st it's not final yet, 2nd couldn't find enough documentation or tutorials to learn it in depth, probably because of the 1st reason, 3rd I'm using mostly Blender 2.8 and AFAIK it's not updated yet, I spent some time trying to figure out it's structure and how to link the different nodes myself but I wasn't successful. If I was a full time motion graphics artist I would've tried harder, but I'm not, I just needed this thing this time for a project – Georges Apr 12 at 1:27
• I need to correct some information in my previous comment, apparently, Animation Nodes is already on Blender 2.8, I tried to do the same in Animation Nodes, I can't say it was easy, but eventually I got it right, so thank you for the tip @SergeL – Georges Apr 14 at 18:16