Created
September 7, 2016 18:49
-
-
Save splinecraft/20c505049add3f0dce6b25e3b3920b27 to your computer and use it in GitHub Desktop.
Maya Iterative keyframe offsetter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://blog.cameronleger.com/mel/offsetkeys/ | |
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; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment