How to list "all" drivers completely?


I found a genius script, which dumps all drivers of a blend file into a text.
A resulting line looks like this one:[“Box”].pose.bones[“LidDrv”].rotation_euler (a+0.3*b)

I need to know, from which vars “a” and “b” are build …?

How can I do access this information via Python scripting?


This is the python expression. It means the driver expression has 2 variables, named a and b. It looks like this :

You can access a driver variable with driver.variables (docs).
Here you can find the variable properties.

And here the target properties.

So if you want to get all targets of a driver’s variable :

for driver in obj.animation_data.drivers:
     for variable in driver.variables:
         for target in variable.targets:

Hi Gorgious,
thank you VERY much for the code! It helps me more than you may think! :slight_smile:

The resulting script is for debugging purposes of my main problem - another script I wrote to batch rename bones in a way, that everything, which depends on it will be renamed/rearranged in a way, that the whole logic of a blend file does not fall apart.

Current status:
The script renames bones and vertex groups according to some regex.
Problem: After the script has finished, a lot of drivers will be marked as “erroneous” in the driver
Interestingly when I rename a bone by hand via Blender (that is: not via script), this does not happen.
So I “need to rename the driver” (or what else action I need to perform with “the driver”) also.
How can I do that…?

Do I need any other entities in a blend file, which depends on the name of bones?

Cheers and have a nice weekend!

Apparently you need to explicitely update the driver once you changed its settings with python. This thread explains that changing the expression triggers an update :

So you might try : driver.expression = driver.expression # Should update the driver