copying drivers

i have a scene with over 1500 objects in, all these objects have a material that changes color when one of the objects rotates. i used a driver for the diffuse channel and set it to z rotation in the driver variable. i have then made the material for all the objects as single users so the rotation only effects the material on that object the only problem is the variable ob/bone option does not stay relative to the object and manually going through and changing each is a head ache. is there anyway to make the variable relative to the object when copying or through the use of a script.

any help is much appreciated

I am not sure about the exact issue, but you could try copying the drives like following …

import bpy

get driver from source object

srcobj = bpy.data.objects[‘Cube’]

copy driver to selected objects

for obj in bpy.context.selected_objects:
for i in range(0,3):
srcdrv = srcobj.active_material.animation_data.drivers[i].driver
srcvar = srcdrv.variables[0]
print(srcvar.name)

    drv = obj.active_material.driver_add('diffuse_color')[i].driver
    drv.type = 'SCRIPTED'
    var = drv.variables.new()
    var.name = srcvar.name
    var.type = srcvar.type 
    tar = var.targets[0]
    tar.id = srcvar.targets[0].id
    tar.transform_type = srcvar.targets[0].transform_type
    drv.expression = srcvar.name
    print(drv.expression)