Possible to add a location driver for single channel?

I am able to add a location driver for all 3 channels at once but this isn’t what I need. I’d like to add a driver only to the z channel. Is this possible?

I’m adding the driver this way.


bpy.data.objects[ob.name].driver_add("location")

Thanks for the help!

Pass it an index, z is 2:

bpy.data.objects[ob.name].driver_add(“location”, 2)

Note: it doesn’t accept keyword arguments unlike keyframe_insert()!

Thanks so much! What could I have done in order to find this out on my own? Or, what is the convention that this follows so I would know to try it in the future? Thanks again.

search the API docs for driver_add, first match
http://www.blender.org/api/blender_python_api_2_72_release/bpy.types.bpy_struct.html?highlight=driver_add#bpy.types.bpy_struct.driver_add

It doesn’t tell you that it expects the index as positional argument, but Python will raise an exception if you try to pass a keyword argument.

I see it now. I have been trying my best to find things in the documentation before I ask a question. Its just a ‘tiny’ bit overwhelming. :slight_smile: As much as I try to understand the docs a lot of the time the information (syntax) just becomes a jumble in my brain and I can’t see the answer that’s right there.