Go to: Synopsis. Return value. Related. Flags. Python examples.
snapKey(
animatedObject
, [animation=string], [attribute=string], [controlPoints=boolean], [float=floatrange], [hierarchy=string], [includeUpperBound=boolean], [index=uint], [shape=boolean], [time=timerange], [timeMultiple=float], [valueMultiple=float])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
snapKey is undoable, NOT queryable, and NOT editable.
This command operates on a keyset. A keyset is defined as a group of keys within a specified time range on one or more animation curves.The animation curves comprising a keyset depend on the value of the "-animation" flag:
Note that the "-animation" flag can be used to override the curves uniquely identified by the multi-use "-attribute" flag, which takes an argument of the form attributeName, such as "translateX".
Keys on animation curves are identified by either their time values or their indices. Times and indices can be given individually or as part of a list or range.
This command "snaps" all target key times and/or values so that they have times and/or values that are multiples of the specified flag arguments. If neither multiple is specified, default is time snapping with a multiple of 1.0. Note that this command will fail to move keys over other neighboring keys: a key's index will not change as a result of a snapKey operation.
TbaseKeySetCmd.h
int | Number of animation curves with keys that were not snapped because of time-snapping conflicts. |
Long name (short name) | Argument types | Properties | ||
---|---|---|---|---|
animation(an)
|
string
|
![]() |
||
|
||||
attribute(at)
|
string
|
![]() ![]() |
||
|
||||
controlPoints(cp)
|
boolean
|
![]() |
||
|
||||
float(f)
|
floatrange
|
![]() ![]() |
||
|
||||
hierarchy(hi)
|
string
|
![]() |
||
|
||||
includeUpperBound(iub)
|
boolean
|
![]() |
||
|
||||
index(index)
|
uint
|
![]() ![]() |
||
|
||||
shape(s)
|
boolean
|
![]() |
||
|
||||
time(t)
|
timerange
|
![]() ![]() |
||
|
||||
timeMultiple(tm)
|
float
|
![]() |
||
|
||||
valueMultiple(vm)
|
float
|
![]() |
||
|
![]() |
![]() |
![]() |
![]() |
import maya.cmds as cmds # Two ways to snap all keys on nurbsSphere1 to integer values. # cmds.snapKey( 'nurbsSphere1', tm=1.0 ) cmds.snapKey( 'nurbsSphere1' ) # Snap active objects' keys between times 10 and 20 so that # they have times that are multiples of 0.5. # cmds.snapKey( t=(10,20), tm=0.5 ) # Snap active objects' keys between times 10 and 20 so that # they have times that are multiples of 0.5 and values that # are multiples of 1.0. # cmds.snapKey( t=(10,20), tm=0.5, vm=1.0 )