Maya Iterative Keyframe Offsetter

This is a small MEL script to copy, paste, and offset keyframes iteratively on multiple objects. First, copy the keyframes from the first object. Then, select the rest of the objects to paste the animation to. The offset value is how many frames to offset the animation for each object. The start value is the frame the entire animation should start on. For each object selected in the order that they are selected, it pastes the animation offset by the amount you chose per each object.

To use this script, you should paste the following into the MEL section of the Script Window, and then execute the code. Or you could drag the selected code in the MEL tab to the Shelf to create a shelf item for it.

if ( `window -exists window` )
	deleteUI window;
window -title "keyOffset" window;
columnLayout;
int $val1 = 0;
int $val2 = 0;
intSliderGrp -label "FrameOffset" -minValue 0 -maxValue 100  -field true -v $val1 refle1;
intSliderGrp - label "StartFrame" -minValue 0 -maxValue 1600 -field true -v $val2 refle2;
rowColumnLayout -numberOfColumns 3;
button -l "EXIT" -c exit;
button -l "COPY" -c copy;
button -l "PASTE" -c sel;
showWindow window ;

proc sel() {
	int $value = `intSliderGrp -q -v refle1`;
	int $value2 = `intSliderGrp -q -v refle2`;
	int $selIndex;
	string $objs[] = `ls -sl`;
	int $offset;
	int $timestart;	for ($selIndex = 0; $selIndex < size($objs); $selIndex++){
		$offset += $value;
		$timestart = $value2 - $value;
		select $objs[$selIndex];
		eval ("pasteKey -time "  +  $timestart +  " -float 0 -option merge -copies 1 -connect 0 -timeOffset "  +  $offset +  " -floatOffset 10 -valueOffset 0") ;
	}};

proc copy() {
	copyKey -time ":" -hierarchy below -controlPoints 0 -shape 1 ;
}

proc exit() {
	deleteUI window;
};

2 Responses

  1. Johannus Johansen
    Johannus Johansen at · Reply

    Thank you so much, you just saved my day! I’ve been looking for this script for days! I had 500 pieces to offset and I just couldn’t do it with the dope sheet manually, because Maya was crashing all the time if I tried…

    This is an awesome script!

    Cheers!

  2. John
    John at · Reply

    Cool thank you 🙂

Leave a Reply to Johannus Johansen Cancel reply