Skip to content

Instantly share code, notes, and snippets.

@dgovil
Last active December 17, 2015 11:19
Show Gist options
  • Save dgovil/5600960 to your computer and use it in GitHub Desktop.
Save dgovil/5600960 to your computer and use it in GitHub Desktop.
Create maya key pairs
import maya.cmds as mc
objs = mc.ls(sl=1)
keyframes = mc.keyframe(objs,q=1)
fs = int( mc.playbackOptions(q=1, ast=1 ) )
fe = int( mc.playbackOptions(q=1, aet=1 ) )
keyframes = sorted( [k for k in set(keyframes) if k>=fs and k<=fe] )
for k in keyframes:
mc.setKeyframe(objs,t=[k],i=True)
for a,b in zip(keyframes,keyframes[1:]):
if b - a < 3:
print b-a
continue
for o in objs:
mc.copyKey(o,t=(a,a))
mc.pasteKey(o,t=(b-1,b-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment