How to get driver value via python?

enter image description here

dr = bpy.data.objects["Cube"].animation_data.drivers[0]

1 Answer 1


Look at the value of the driven property.

In the example given in question, the bevel modifier width of one cube is being driven by that of another. Have set up similar, the driver value being displayed via UI is 0.2

Given the object of interest has context, retrieve this value by simply

>>> bm = C.object.modifiers['Bevel']
>>> bm.width

Or from the driver, similarly to above a quick visual check confirms the driver is the zeroth

>>> for i, fc in enumerate(C.object.animation_data.drivers):
...     i, fc.data_path
(0, 'modifiers["Bevel"].width')

>>> driver_fcurve = C.object.animation_data.drivers[0]
>>> dp = driver_fcurve.data_path
>>> dp

And hence the value,

>>> C.object.path_resolve(dp)

If the value resolves to an iterable will require using the array_index of the driver [Look for link.]

Consider investigating custom properties as input data to drive from. For set up like above all drivers will break if the driver variable target object with the modifier is removed.

A custom property on the scene can be used as a global and on the object as a local (the use_self option is handy for this)

  • $\begingroup$ Note that this solution will work on render only if the user did not locked his interface $\endgroup$
    – Fox
    Oct 27, 2022 at 13:26

You must log in to answer this question.

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