When using Python to add a driver to a vector, i.e. the constant offset of an array modifier, it adds drivers to all three components while I only need to drive one of them.

Is there a way to add a driver to only one component, or perhaps to add drivers to all three and then delete the unnecessary two?

Here's how I add the driver:

arr_mod = active_object.modifiers.new("Array", 'ARRAY')
fcurves = arr_mod.driver_add('constant_offset_displace')
  • $\begingroup$ Post a minified code snippet showing your problem - the fix is simple you need to define which channel to drive… $\endgroup$ Oct 2 at 13:19
  • $\begingroup$ Thanks Markus. I've updated my question with a code snippet. $\endgroup$
    – gcs_dev
    Oct 2 at 13:41

1 Answer 1


Here's an updated snippet that adds a driver only to the $y$ component of the constant offset:

from bpy import context as C

arr_mod = C.object.modifiers.new("Array", 'ARRAY')
arr_mod.use_constant_offset = True
fcurves = arr_mod.driver_add('constant_offset_displace', 1)

Probably needless to say, the $xyz$ components have $0, 1, 2$ indices in that order.

When writing the code in the Python Console, you can hit ⭾ Tab after opening parenthesis of driver_add( to see hints on how to use it:

  • 1
    $\begingroup$ Wow! So simple. Thanks a lot Markus, that's a great answer! $\endgroup$
    – gcs_dev
    Oct 2 at 14:58

You must log in to answer this question.

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