Skip to content

Instantly share code, notes, and snippets.

@dgovil
Created June 3, 2013 01:08
Show Gist options
  • Save dgovil/5695617 to your computer and use it in GitHub Desktop.
Save dgovil/5695617 to your computer and use it in GitHub Desktop.
Set whatever object you want as the master object. It'll clean up all the other selected controllers to only have keyframes when the master controller does.
masterObject = "controllerName"
import maya.cmds as mc
objs = mc.ls(sl=1)
keyframes = mc.keyframe(masterObject,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] )
objs = mc.ls(sl=1)
for f in range(fs,fe+1):
if f in keyframes:
mc.setKeyframe(objs,t=[f],i=True)
for f in range(fs,fe+1):
if f not in keyframes:
mc.cutKey(objs, time=(f,f) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment