6
$\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$

1 Answer 1

8
$\begingroup$
import bpy

obj = bpy.context.active_object
driver = obj.data.shape_keys.key_blocks['Key 1'].driver_add("value")
$\endgroup$
1
  • 2
    $\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, 2018 at 8:18

You must log in to answer this question.

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