2
$\begingroup$

I'm trying to get the name of the property that's been affected by a driver for a certain object, what I did so far:

for d in bpy.context.object.animation_data.drivers:
    print(d.driver.id_data.name)

However, that's returning the name of the object, not the driven property.
My question is, let's say there's a drive controlling the Z Scale, how do I get that information "Z Scale" or a similar equivalent, in scripting?

$\endgroup$
4
  • $\begingroup$ Related blender.stackexchange.com/questions/111662/… $\endgroup$
    – batFINGER
    Oct 26, 2020 at 11:45
  • $\begingroup$ Thank you @batFINGER very helpful, as always $\endgroup$
    – Georges D
    Oct 26, 2020 at 11:47
  • 1
    $\begingroup$ Cheers. Initially closed as a dupe, ... changed mind after looking at answer script which will do nought if there are no variables, which is often the case with use_self or when using frame or other vars known to namespace. Closing is no big deal tho, more in re to linking alike questions. $\endgroup$
    – batFINGER
    Oct 26, 2020 at 12:01
  • $\begingroup$ Totally agree, I believe answers to both questions are helpful $\endgroup$
    – Georges D
    Oct 26, 2020 at 12:08

1 Answer 1

4
$\begingroup$

Use f_curve.data_pathand f_curve.array_index to get the property index in case of vectorized properties (like location, scale, etc.)

import bpy

if bpy.context.active_object and bpy.context.active_object.animation_data:
    for d in bpy.context.active_object.animation_data.drivers:
        print(bpy.context.active_object)
        print(f"Driven property : {d.data_path}")
        print(f"Property index : {d.array_index}")

Example :

enter image description here

enter image description here

$\endgroup$
1
  • $\begingroup$ Great answer, thank you $\endgroup$
    – Georges D
    Oct 26, 2020 at 11:40

You must log in to answer this question.

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