I'm writing an addon for Blender 2.8. I have an object and want to drive the Y & Z Scale with the X Scale. Doing it manually with right click on the Scale shows me these commands:



How can I get these commands in my Python script to work?

Right click on scale

P.S.: I managed to insert a driver at X Scale like this:

driver_scale_y = bpy.context.object.driver_add("scale", 1)

Maybe this could be a starting point.


1 Answer 1


The bpy.ops.ui.copy_as_driver_button() and bpy.ops.anim.paste_driver_button() functions are operators in Blender's Python API, which means they are designed to be called from the Blender interface. As far as I know, it's not possible to call these functions directly from a Python script.

Instead of using these functions, you can achieve the same result by accessing the data that the operator manipulates directly. For example, you could use the driver_add() method of a property to add a new driver. In the following example, I add a driver to the default cube's X and Y scale properties, which are indices 0 and 1, respectively:

import bpy

obj = bpy.data.objects["Cube"]

def add_driver(ob, idx):
    fc = ob.driver_add('scale', idx)
    d = fc.driver
    d.type = "AVERAGE"
    v = d.variables.new()
    t = v.targets[0]
    t.id_type = 'OBJECT'
    t.id = ob
    t.data_path = "scale[2]"

add_driver(obj, 0)
add_driver(obj, 1)

Now you can adjust the Z scale and have X and Y scales update to the same values.

See the thread How can I add and configure a Driver through a Script for more information about scripting drivers.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .