I am writing a script and this script required adding a driver to an object,so I added it but I have 2 problems with it.

  1. I have added a single property variable and set its ID and path. After I run the script, the variable added correctly and everything is fine, but I see that the path is colored in red and Blender said that my driver failed. I figure how to fix this, by selecting the ID object (spin object) one more time (which is already selected) as shown in the figure. So how can I fix this? Because I don't want to do this every time I run the script. and here is the script and the image.

    newVar.name = "Array"
    newVar.type = 'SINGLE_PROP'
    newVar.targets[0].id = bpy.data.objects['Spin object']
    newVar.targets[0].data_path = 'modifiers["Array"].count'

enter image description here

  1. When I change the value of the variable (array count), I didn't see the effect until I press update dependencies. I want it to be updated without pressing update dependencies every time I change the value of the variable. How can I do this?
  • 1
    $\begingroup$ That is a script fragment. I can not reproduce your problem without making a LOT of assumptions about the rest of the script. Did you create the modifier before or after the driver? You should probably include a copy of the script that can reproduce the problem when it's run from a brand new .blend file containing the default cube. Failing that, give us some more detailed instructions on how to reproduce the problem. $\endgroup$
    – Mutant Bob
    Commented Nov 25, 2014 at 19:05
  • $\begingroup$ well,thanks you are right,I have added the modifier after adding the driver not before it,so this is the 1st problem solved,do you know the 2nd problem? $\endgroup$
    – Omar Emara
    Commented Nov 26, 2014 at 9:21

1 Answer 1


I think this is a limitation of the current dependency graph.

The way I would handle it is to add a custom property to the object, than add a driver to the array count that uses the custom value, set this other driver to also use the custom property.

As answered in the comments, you also need to overcome the chicken and the egg theory when creating drivers.


  1. Add a new custom property to the object. in the UI you click the add button, in python there is nothing special, you just give the property a value and it gets created.

    bpy.data.objects['Cube']['myControl'] = 1

  2. Add a driver to the count value of the array modifier

enter image description here

  1. Add the same driver settings for the other item that previous read modifiers['Array'].count

Now when you change the myControl value, both items will use the same value. You can create a panel wherever you like to display the custom property or add it to an existing panel.

  • $\begingroup$ the array count value updated properly but I still have to press update dependencies or refresh the Scene so the rotation of the empty that I put the 1st driver updated. $\endgroup$
    – Omar Emara
    Commented Nov 27, 2014 at 15:51
  • $\begingroup$ Are you pointing the empty.rotation to 'myControl' or to array.count? $\endgroup$
    – sambler
    Commented Nov 27, 2014 at 16:02
  • $\begingroup$ actually,it works,I forget to change the path,thanks $\endgroup$
    – Omar Emara
    Commented Nov 27, 2014 at 16:15

You must log in to answer this question.

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