pymel.core.animation.pasteKey

pasteKey(*args, **kwargs)

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 objectsClipboard 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 cutKeyor copyKeycommands). We will call the animation curve that we are pasting to the target curve: pasteKey -time 5 -option insert1. 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 replace1. Remove all keys on the target curve from 5 to 25.2. Paste the 20-frame clipboard curve at time 5.pasteKey -option replaceCompletely1. 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 merge1.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 untouchedpasteKey -time “3:10” -option scaleInsert1. 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 scaleReplace1. 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 scaleMerge1. 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 fitInsert1. 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 fitReplace1. 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 fitMerge1. 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.

Flags:
Long name (short name) Argument Types Properties
animation (an) unicode ../../../_images/create.gif
 

Where this command should get the animation to act on. Valid values are “objects,” “keys,” and “keysOrObjects” Default: “keysOrObjects.” (See Description for details.)

attribute (at) unicode ../../../_images/create.gif
 
List of attributes to select
clipboard (cb) unicode ../../../_images/create.gif
 
Specifies the clipboard from which animation is pasted. Valid clipboards are “api” and “anim”. The default clipboard is: anim
connect (c) bool ../../../_images/create.gif
 

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) int ../../../_images/create.gif
 
The number of times to paste the source curve.
float (f) floatrange ../../../_images/create.gif
 

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”)

floatOffset (fo) float ../../../_images/create.gif
 
How much to offset the pasted keys in time (for non-time-input animation curves).
includeUpperBound (iub) bool ../../../_images/create.gif
 

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.)

index (index) int ../../../_images/create.gif
 
index of a key on an animCurve
matchByName (mn) bool ../../../_images/create.gif
 

When true, we will only paste onto items in the scene whose node and attribute names match up exactly with a corresponding item in the clipboard. No hierarchy information is used. Default is false, and in this case the usual matching by hierarchy occurs.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

option (o) unicode ../../../_images/create.gif
 

Valid values are “insert”, “replace”, “replaceCompletely”, “merge”, “scaleInsert,” “scaleReplace”, “scaleMerge”, “fitInsert”, “fitReplace”, and “fitMerge”. The default paste option is: “insert”.

time (t) timerange ../../../_images/create.gif
 

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”)

timeOffset (to) time ../../../_images/create.gif
 
How much to offset the pasted keys in time (for time-input animation curves).
valueOffset (vo) float ../../../_images/create.gif
 
How much to offset the pasted keys in value.

Derived from mel command maya.cmds.pasteKey

Example:

import pymel.core as pm

import maya.cmds as cmds

# Paste keyframes onto nurbsSphere1's translateX attribute at time 10
#
pm.pasteKey( 'nurbsSphere1', time=(10,10), attribute='translateX' )

# Paste to all active objects, preserving the timing from the clipboard.
#
pm.pasteKey()

Previous topic

pymel.core.animation.parentConstraint

Next topic

pymel.core.animation.pathAnimation

Core

Core Modules

Other Modules

This Page