add_driver
Creates a Blender driver that links an object property to an expression or other properties, enabling motion such as doors opening, wheels spinning, or lights dimming.
Instructions
Drive a property from other properties or the frame: a door that opens as a handle turns, a wheel that spins as a car moves, a light that dims with distance.
Expressions use Blender's simple subset, evaluated without Python: numbers, + - * / % //, comparisons, and/or/not, "a if c else b", parentheses, the variables below, frame, pi, and sin cos tan asin acos atan atan2 sqrt abs fabs floor ceil trunc round int min max radians degrees exp log pow fmod lerp clamp smoothstep. No ** (use pow).
Args: object_name: Object that owns the driven property. data_path: Property to drive, e.g. "location", "rotation_euler", "data.energy" (a light's power), 'modifiers["Bend"].angle', 'data.shape_keys.key_blocks["Smile"].value'. Paths into the object's data or shape keys are driven on that data. expression: SCRIPTED drivers only, e.g. "lx * 2" or "sin(frame / 10)". index: Component of a vector property (0, 1, 2 for X, Y, Z), or -1 for a single value. driver_type: SCRIPTED (use the expression), or AVERAGE, SUM, MIN, MAX of the variables. variables: Up to 32, each {"name", "type", "object", ...}: TRANSFORMS: "transform_type" LOC_X..SCALE_AVG, optional "transform_space" WORLD_SPACE (default), LOCAL_SPACE or TRANSFORM_SPACE. SINGLE_PROP: "data_path" on the object, e.g. "data.energy". LOC_DIFF / ROTATION_DIFF: distance or angle between "object" and "object_2".
Returns: Dict with the driven path, index, expression and variables.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | No | ||
| data_path | Yes | ||
| variables | No | ||
| expression | No | ||
| driver_type | No | SCRIPTED | |
| object_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||