4
$\begingroup$

how can i add a driver for a shapekey via python?

shape_keys.animation_data.driver_button_add(True)

or

obj=bpy.context.active_object
obj.driver_add('key_blocks["Eye_left"].value')

The Problem is that it can't find the shape key and shape keys are getting their driver with a different method; so I'm a bit confused how it can be added by python correctly. Sorry I'm new to Python. Thanks for your help!

$\endgroup$
6
$\begingroup$
import bpy

obj = bpy.context.active_object
driver = obj.data.shape_keys.key_blocks['Key 1'].driver_add("value")
$\endgroup$
  • $\begingroup$ Docs say driver_add() returns a FCurve object, so you don't have the driver yet: driver = obj.data.shape_keys.key_blocks['Key 1'].driver_add("value").driver (docs.blender.org/api/2.79/…) $\endgroup$ – R. Navega Mar 14 '18 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.