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

Synopsis

setKeyframe [-adjustTangent boolean] [-animLayer string] [-animated boolean] [-attribute string] [-breakdown boolean] [-clip string] [-controlPoints boolean] [-dirtyDG boolean] [-float float] [-hierarchy string] [-identity] [-inTangentType string] [-insert] [-insertBlend boolean] [-minimizeRotation boolean] [-noResolve boolean] [-outTangentType string] [-preserveCurveShape boolean] [-respectKeyable boolean] [-shape boolean] [-time time] [-useCurrentLockedWeights boolean] [-value float] [objects]

setKeyframe is undoable, queryable, and editable.

This command creates keyframes for the specified objects, or the active objects if none are specified on the command line.

The default time for the new keyframes is the current time. Override this behavior with the "-t" flag on the command line.

The default value for the keyframe is the current value of the attribute for which a keyframe is set. Override this behavior with the "-v" flag on the command line.

When setting keyframes on animation curves that do not have "time" as an input attribute (ie, they are unitless animation curves), use "-f/-float" to specify the unitless value at which to set a keyframe.

The -time and -float flags may be combined in one command.

This command sets up Dependency Graph relationships for proper evaluation of a given attribute at a given time.

Return value

intNumber of keyframes set by this command.

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

Related

autoKeyframe, findKeyframe, setDrivenKeyframe, setKeyPath

Flags

adjustTangent, animLayer, animated, attribute, breakdown, clip, controlPoints, dirtyDG, float, hierarchy, identity, inTangentType, insert, insertBlend, minimizeRotation, noResolve, outTangentType, preserveCurveShape, respectKeyable, shape, time, useCurrentLockedWeights, value
Long name (short name) Argument types Properties
-adjustTangent(-adt) boolean create
Adjsut tangent if insert keys
-animLayer(-al) string create
Specifies that the new key should be placed in the specified animation layer. Note that if the objects being keyframed are not already part of the layer, this flag will be ignored.
-animated(-an) boolean create
Add the keyframe only to the attribute(s) that have already a keyframe on. Default: false
-attribute(-at) string createmultiuse
Attribute name to set keyframes on.
-breakdown(-bd) boolean createqueryedit
Sets the breakdown state for the key. Default is false
-clip(-c) string create
Specifies that the new key should be placed in the specified clip. Note that if the objects being keyframed are not already part of the clip, this flag will be ignored.
-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.
-dirtyDG(-dd) boolean create
Allow dirty messages to be sent out when a keyframe is set.
-float(-f) float createmultiuse
Float time at which to set a keyframe on float-based animation curves.
-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"
-identity(-id) create
Sets an identity key on an animation layer. An identity key is one that nullifies the effect of the anim layer. This flag has effect only when the attribute being keyed is being driven by animation layers.
-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) 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.
-minimizeRotation(-mr) boolean create
For rotations, ensures that the key that is set is a minimum distance away from the previous key. Default is false
-noResolve(-nr) boolean create
When used with the -value flag, causes the specified value to be set directly onto the animation curve, without attempting to resolve the value across animation layers.
-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"
-preserveCurveShape(-pcs) boolean create
Sets the preserve curve shape when inserting keys. Default value depend on your keySetPreserveCurveShape option.
-respectKeyable(-rk) boolean create
When used with the -attribute flag, prevents the keying of the non keyable attributes.
-shape(-s) boolean create
Consider attributes of shapes below transforms as well, except "controlPoints". Default: true
-time(-t) time createmultiuse
Time at which to set a keyframe on time-based animation curves.
-useCurrentLockedWeights(-lw) boolean create
If we are setting a key over an existing key, use that key tangent's locked weight value for the new locked weight value. Default is false
-value(-v) float create
Value at which to set the keyframe. Using the value flag will not cause the keyed attribute to change to the specified value until the scene re-evaluates. Therefore, if you want the attribute to update to the new value immediately, use the setAttr command in addition to setting the key.

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 be used more than once in a command.

MEL examples

// Set a keyframe at the current time on all "keyable"
// attributes of the selected objects.
//
setKeyframe;

// Set a keyframe so that translateX has a value of 10
// at the current time, regardless of its current position
//
setKeyframe -v 10 -at translateX;

// Set keyframes for translateX on two objects at t=0 and
// t=10 seconds.  (Note that if mysteryObject has no
// attribute named translateX, no keyframe is set for mysteryObject.)
//
setKeyframe -attribute "translateX" -t 0sec -t 10sec nurbsSphere1 mysteryObject;