1
$\begingroup$

I wish to be able to reference the driver for Location Z by name. Whenever I try using somethings like

object.animation_data.drivers[object.location.z]

or

object.animation_data.drivers[object.location[2]]

I get

TypeError:bpy_prop_collection[key]: invalid key, must be a string or an int, not Float

Any object I will call this function on will have a driver for Z location. Instead of iterating through the collection I was hoping I can call it by name (like properties).

$\endgroup$

1 Answer 1

1
$\begingroup$

I was able to find in the API documentation that there is a built in function for this collection.

Calling

object.animation_data.drivers.find('location',2)

did the trick.

$\endgroup$
2
  • $\begingroup$ If this "did the trick", accept your answer to avoid community bot bump. $\endgroup$
    – batFINGER
    Jan 27, 2019 at 10:12
  • $\begingroup$ My apologies. I have accepted the answer. Thanks $\endgroup$ Jan 28, 2019 at 16:52

You must log in to answer this question.

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