Drivers
An AnimData block contains a list of all drivers as FCurves references. The driver contains a list of driver variables. Each variable contains a list of targets, which only contains more than one target if the type of the variable is "Rotational Difference" or "Distance". The target datablock references a data asset (like an object, scene, collection, bone...) and stores the data path as a string.
The driver also stores the expression as a string.
AnimData → Driver → DriverVariable → DriverTarget
Driver Variable Type
SINGLE_PROPSingle Property – Use the value from some RNA property.TRANSFORMSTransform Channel – Final transformation value of object or bone.ROTATION_DIFFRotational Difference – Use the angle between two bones.LOC_DIFFDistance – Distance between two bones or objects.CONTEXT_PROPContext Property – Use the value from some RNA property within the current evaluation context.
Driver Target
These are options for some important values:
rotation_mode
- AUTO: Auto Euler. Euler using the rotation order of the target.
- XYZ: Euler using the XYZ rotation order.
- XZY: Euler using the XZY rotation order.
- YXZ: Euler using the YXZ rotation order.
- YZX: Euler using the YZX rotation order.
- ZXY: Euler using the ZXY rotation order.
- ZYX: Euler using the ZYX rotation order.
- QUATERNION
- SWING_TWIST_X: Swing and X Twist.
- SWING_TWIST_Y: Swing and Y Twist.
- SWING_TWIST_Z: Swing and Z Twist.
Decompose into a swing rotation to aim the axis, followed by twist around it.
transform_space
WORLD_SPACETransforms include effects of parenting/restpose and constraints.TRANSFORM_SPACETransforms don’t include parenting/restpose or constraints.LOCAL_SPACETransforms include effects of constraints but not parenting/restpose.
Script Examples
To list all transformation drivers:
obj = bpy.context.active_object
for fc in obj.animation_data.drivers:
print(f"- Driver of type \"{fc.driver.type}\": {fc.driver.expression}")
for v in fc.driver.variables:
print(f"-- Variable {v.name}")
for t in v.targets:
print(f"--- Target {t.id.name}: {t.data_path}")