Go to: Synopsis. Return value. Related. Flags. Python examples.
pasteKey(
[objects]
, [animation=string], [attribute=string], [clipboard=string], [connect=boolean], [copies=uint], [float=floatrange], [floatOffset=float], [includeUpperBound=boolean], [index=uint], [option=string], [time=timerange], [timeOffset=time], [valueOffset=float])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
pasteKey is undoable, queryable, and editable.
The pasteKey command pastes curve segment hierarchies from the
clipboard onto other objects or curves. If the object hierarchy
from which the curve segments were copied or cut does not match
the object hierarchy being pasted to, pasteKey will paste as much
as it can match in the hierarchy. If animation from only one object
is on the clipboard, it will be pasted to each of the target objects.
If animation from more than one object is on the clipboard, selection
list order determines what animation is pasted to which object.
Valid operations include:
- One attribute to one or more attributes (Clipboard
animation is pasted onto all target attributes.
- One attribute to one or more objects (Clipboard animation
pasted onto target object, when attribute names match.)
- Many attributes to one or more objects
- Clipboard animation pasted onto targets when attribute names
match.
TbaseKeySetCmd.h
The way the keyset clipboard will be pasted to the specified object's
attributes depends on the paste "-option" specified. Each of these
options below will be explained using an example. For all the
explanations, let us assume that there is a curve segment
with 20 frames of animation on the keyset clipboard (you can put
curve segments onto the clipboard using the cutKey or
copyKey commands). We will call the animation curve that
we are pasting to the target curve:
- pasteKey -time 5 -option insert
1. Shift all keyframes on the target curve after time 5 to the right
by 20 frames (to make room for the 20-frame clipboard segment).
2. Paste the 20-frame clipboard segment starting at time 5.
- pasteKey -time "5:25" -option replace
1. Remove all keys on the target curve from 5 to 25.
2. Paste the 20-frame clipboard curve at time 5.
- pasteKey -option replaceCompletely
1. Remove all keys on the target curve.
2. Paste the 20-frame clipboard curve, preserving
the clipboard curve's original keyframe times.
- pasteKey -time 5 -option merge
1.The clipboard curve segment will be pasted starting at time 5
for its full 20-frame range until frame 25.
2. If a keyframe on the target curve has the same time
as a keyframe on the clipboard curve, it is overwritten.
Otherwise, any keys that existed in the 5:25 range
before the paste, will remain untouched
- pasteKey -time "3:10" -option scaleInsert
1. Shift all keyframes on the target curve after time 3 to the right
by 7 frames (to clear the range 3:10 to paste in)
2. The clipboard curve segment will be scaled to fit the specified
time range (i.e. the 20 frames on the clipboard will be scaled to
fit into 7 frames), and then pasted into the range 3:10.
- pasteKey -time "3:10" -option scaleReplace
1. Any existing keyframes in the target curve in the range 3:10
are removed.
2. The clipboard curve segment will be scaled to fit the specified
time range (i.e. the 20 frames on the clipboard will be scaled to
fit into 7 frames), and then pasted into the range 3:10.
- pasteKey -time "3:10" -option scaleMerge
1. The clipboard curve segment will be scaled to fit the specified
time range (i.e. the 20 frames on the clipboard will be scaled to
fit into 7 frames).
2. If there are keys on the target curve at the same time
as keys on the clipboard curve, they are overwritten.
Otherwise, keyframes on the target curve that
existed in the 3:10 range before the paste, will
remain untouched.
- pasteKey -time "3:10" -option fitInsert
1. Shift all the keyframes on the target curve after time 3 to the right
by 7 frames (to clear the range 3:10 to paste in)
2. The first 7 frames of the clipboard curve segment will be
pasted into the range 3:10.
- pasteKey -time "3:10" -option fitReplace
1. Any existing frames in the target curve in the range 3:10
are removed.
2. The first 7 frames of the clipboard curve segment will be
pasted into the range 3:10.
- pasteKey -time "3:10" -option fitMerge
1. The first 7 frames of the clipboard curve segment
will be pasted into the range 3:10.
2. If there are keys on the target curve at the same time
as keys on the clipboard curve, they are overwritten.
Otherwise, keyframes on the target curve that
existed in the 3:10 range before the paste, will
remain untouched.
int | The number of curves pasted |
In query mode, return type is based on queried flag.
copyKey, cutKey, findKeyframe, keyTangent, keyframe, keyframeOutliner, keyframeStats, scaleKey, setInfinity, snapKey
animation, attribute, clipboard, connect, copies, float, floatOffset, includeUpperBound, index, option, time, timeOffset, valueOffset
Long name (short name) |
Argument types |
Properties |
attribute(at)
|
string
|
|
|
List of attributes to select
In query mode, this flag needs a value.
|
|
option(o)
|
string
|
|
|
Valid values are "insert", "replace",
"replaceCompletely", "merge", "scaleInsert,"
"scaleReplace", "scaleMerge", "fitInsert",
"fitReplace", and "fitMerge". The default paste
option is: "insert".
|
|
clipboard(cb)
|
string
|
|
|
Specifies the clipboard from which animation is pasted.
Valid clipboards are "api" and "anim". The default clipboard
is: anim
|
|
connect(c)
|
boolean
|
|
|
When true, connect the source curve with the
destination curve's value at the paste time.
(This has the effect of shifting the clipboard curve
in value to connect with the destination curve.)
False preserves the source curve's original keyframe
values. Default is false.
|
|
copies(cp)
|
uint
|
|
|
The number of times to paste the source curve.
|
|
timeOffset(to)
|
time
|
|
|
How much to offset the pasted keys in time (for time-input
animation curves).
|
|
floatOffset(fo)
|
float
|
|
|
How much to offset the pasted keys in time (for non-time-input
animation curves).
|
|
valueOffset(vo)
|
float
|
|
|
How much to offset the pasted keys in value.
|
|
index(index)
|
uint
|
|
|
index of a key on an animCurve
In query mode, this flag needs a value.
|
|
time(t)
|
timerange
|
|
|
time uniquely representing a key (or key
range) on a time-based animCurve. Valid timeRanges
include single values (-t 10) or a string
with a lower and upper bound, separated by a colon
(-t "10:20")
In query mode, this flag needs a value.
|
|
float(f)
|
floatrange
|
|
|
value uniquely representing a non-time-based
key (or key range) on a time-based animCurve. Valid
floatRange include single values (-f 10) or a
string with a lower and upper bound, separated by a
colon (-f "10:20")
In query mode, this flag needs a value.
|
|
includeUpperBound(iub)
|
boolean
|
|
|
When the -t/time or -f/float flags represent a range
of keys, this flag determines whether the keys at the
upper bound of the range are included in the keyset.
Default value: true. This flag is only valid when
the argument to the -t/time flag is a time range with
a lower and upper bound. (When used with the "pasteKey"
command, this flag refers only to the time range of the
target curve that is replaced, when using options such
as "replace," "fitReplace," or "scaleReplace." This
flag has no effect on the curve pasted from the clipboard.)
|
|
animation(an)
|
string
|
|
|
Where this command should get the animation to act
on. Valid values are "objects," "keys," and
"keysOrObjects" Default: "keysOrObjects." (See
Description for details.)
|
|
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.
|
import maya.cmds as cmds
# Paste keyframes onto nurbsSphere1's translateX attribute at time 10
#
cmds.pasteKey( 'nurbsSphere1', time=(10,10), attribute='translateX' )
# Paste to all active objects, preserving the timing from the clipboard.
#
cmds.pasteKey()