Go to: Synopsis. Return value. Related. Flags. Python examples.

Synopsis

setDrivenKeyframe( [objects] , [attribute=string], [controlPoints=boolean], [currentDriver=string], [driven=boolean], [driver=boolean], [driverValue=float], [hierarchy=string], [inTangentType=string], [insert=boolean], [insertBlend=boolean], [outTangentType=string], [shape=boolean], [value=float])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

setDrivenKeyframe is undoable, queryable, and editable.

This command sets a driven keyframe. A driven keyframe is similar to a regular keyframe. However, while a standard keyframe always has an x-axis of time in the graph editor, for a drivenkeyframe the user may choose any attribute as the x-axis of the graph editor.

For example, you can keyframe the emission of a faucet so that so that it emits whenever the faucet handle is rotated around y. The faucet emission in this example is called the driven attribute. The handle rotation is called the driver. Once you have used setDrivenKeyframe to set up the relationship between the emission and the rotation, you can go to the graph editor and modify the relationship between the attributes just as you would modify the animation curve on any keyframed object.

In the case of an attribute driven by a single driver, the dependency graph is connected like this:

driver attribute ---> animCurve ---> driven attribute

You can set driven keyframes with more than a single driver. The effects of the multiple drivers are combined together by a blend node.

Return value

intNumber of keyframes set.

In query mode, return type is based on queried flag.

Related

autoKeyframe, findKeyframe, setKeyPath, setKeyframe

Flags

attribute, controlPoints, currentDriver, driven, driver, driverValue, hierarchy, inTangentType, insert, insertBlend, outTangentType, shape, value
Long name (short name) Argument types Properties
attribute(at) string createmultiuse
Attribute name to set keyframes on.
controlPoints(cp) boolean create
Explicitly specify whether or not to include the control points of a shape (see "-s" flag) in the list of attributes. Default: false.
currentDriver(cd) string createquery
Set the driver to be used for the current driven keyframe to the attribute passed as an argument.
driven(dn) boolean query
Returns list of driven attributes for the selected item.
driver(dr) boolean query
Returns list of available drivers for the attribute.
driverValue(dv) float createmultiuse
Value of the driver to use for this keyframe. Default value is the current value.
hierarchy(hi) string create
Controls the objects this command acts on, relative to the specified (or active) target objects. Valid values are "above," "below," "both," and "none." Default is "hierarchy -query"
inTangentType(itt) string create
The in tangent type for keyframes set by this command. Valid values are: "auto", clamped", "fast", "flat", "linear", "plateau", "slow", "spline", and "stepnext" Default is "keyTangent -q -g -inTangentType"
insert(i) boolean create
Insert keys at the given time(s) and preserve the shape of the animation curve(s). Note: the tangent type on inserted keys will be fixed so that the curve shape can be preserved.
insertBlend(ib) boolean create
If true, a pairBlend node will be inserted for channels that have nodes other than animCurves driving them, so that such channels can have blended animation. If false, these channels will not have keys inserted. If the flag is not specified, the blend will be inserted based on the global preference for blending animation.
outTangentType(ott) string create
The out tangent type for keyframes set by this command. Valid values are: "auto", "clamped", "fast", "flat", "linear", "plateau", "slow", "spline", "step", and "stepnext". Default is "keyTangent -q -g -outTangentType"
shape(s) boolean create
Consider attributes of shapes below transforms as well, except "controlPoints". Default: true
value(v) float create
Value to set the keyframe at. Default is the current value.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Create a curve and a cone
#
cmds.curve(d=3,p=[(-10, 0, 0),(-6, 0, 10),(-3, 0, -10),(10, 0, 0)],k=[0, 0, 0, 1, 1, 1])
cmds.polyCone()

# To set the keyframe on the selected object's translateX based on
# curve1's rotateZ:
cmds.setDrivenKeyframe( at='translateX', cd='curve1.rz' )

# To set the keyframe on pCone1.tx based on the value of curve1.rz:
cmds.setDrivenKeyframe( 'pCone1.tx', cd='curve1.rz' )

# To query the current driver of pCone1.tx:
cmds.setDrivenKeyframe( 'pCone1.tx', q=True, cd=True )

# To query the available drivers of pCone1.tx:
cmds.setDrivenKeyframe( 'pCone1.tx', q=True, dr=True )