I am writing a python script to offset some keys on objects.
I get the selected objects, then I want to go through the selected objects and offset each object’s selected keyframes a certain amount.
I can get the selected keys using
cmds.keyframe (query=True, sl=True )
and I can move all selected key of all selected objects using:
but I can’t figure out a way to move only selected keys of a single object from the selected objects list:
import maya.cmds as cmds selected = cmds.ls(sl=True) amount =2 for sel in range (0,len(selected)): cmds.keyframe(selected[sel],edit=True,relative=True,timeChange=sel*int(amount))
the above code moves all keys of selected objects, and not just the selected keys of the selected objects.
I tried getting the selected keys of the selected object inside the for-loop, and feed this variable to the “keyframe” command, instead of the object name (selected[sel]), but I get an error…
anyone can help me get this right?