Tech Tip Tuesday: Insert and Cut Frames

If you’re nostalgic for an old-school 2D lunchbox workflow, you might want to cut and insert frames. The first command will push all your animation forward one frame from the current frame, affectively “inserting” a frame to make your animation longer. The second command will do the opposite, and shift your animation back one frame, after deleting the current keyframe.
MEL:
Insert

keyframe -time (`currentTime -q`+":") -e -r -timeChange 1;

Cut

if(size(`ls -sl`)) cutKey -clear -time `currentTime -q`;
keyframe -time (`currentTime -q`+":") -e -r -timeChange -1;

Python:
Insert:

import maya.cmds as mc
mc.keyframe(time=(str(mc.currentTime(query=True))+':',), edit=True, relative=True, timeChange=1)

Cut:

import maya.cmds as mc
if mc.ls(sl=True):
    mc.cutKey(clear=True, time=(mc.currentTime(query=True),))
mc.keyframe(time=(str(mc.currentTime(query=True))+':',), edit=True, relative=True, timeChange=-1)
Share Button
This entry was posted in Maya, MEL, Python, Tech Tip Tuesday. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *