Offset select objects keys


#1

Using maya.cmds is there an easy way in which I can move all the select objects keys X number of frames?


#2

Hi,

Hope this helps! :slight_smile:

import maya.cmds as cmds
def moveKeys(value=0):
    sel = cmds.ls(sl=True)
    if sel:
        curves = cmds.findKeyframe(sel, curve=True)
        if not curves:
            return
            
        min = cmds.playbackOptions(query=True, minTime=True)
        max = cmds.playbackOptions(query=True, maxTime=True)
    
        cmds.selectKey(curves, time=(min, max))
        cmds.keyframe(animation='keys', option='over', relative=True, timeChange=(0 + value))
        
moveKeys(5) # Move keys on selected objects forwards by 5
moveKeys(-2) # Move keys on selected objects backwards by 2

#3

Perfect this is exactly what i needed. Are you pretty familiar with writing tools for maya?