/* alien Cycle v 1.0 ******what does this script do? this script cycle the animation of the selected object or selected curves by putting keyframe, so you can cycle and then modify the cycled animation. ******what do I have to do to use it? copy this file to your script directory, then map "alienCycle()" to a shortcut or a shelf button ******how can I use it? do the shortcut or click the shelf button,and cycle...awesome!!! ^_^ ******limitations ...no limitations! ^_^ ******thanks to Pava for the idea! ******credits Nicola Danese --> n.danese@ubik.it */ //check for the timeSlider global proc checkTimeS1() { global int $laststartTime; global int $lastEndTime; global int $startTime; global int $endTime; if (`checkBox -q -v chk1`) { $laststartTime = $startTime; $lastEndTime = $endTime; $startTime = `playbackOptions -q -min`; $endTime = `playbackOptions -q -max`; intSliderGrp -e -en false -v $startTime startTimeSlider; intSliderGrp -e -en false -v $endTime endTimeSlider; checkBox -e -en false chk2; } else { $startTime = $laststartTime; $endTime = $lastEndTime; intSliderGrp -e -en true -v $startTime startTimeSlider; intSliderGrp -e -en true -v $endTime endTimeSlider; checkBox -e -en true chk2; } } //check for the whole animation global proc checkTimeS2() { global int $laststartTime; global int $lastEndTime; global int $startTime; global int $endTime; if (`checkBox -q -v chk2`) { $laststartTime = $startTime; $lastEndTime = $endTime; int $tipoDiSelezione= `radioButtonGrp -q -sl tipoDiSelezione`; string $selected[]; if ( $tipoDiSelezione == 2 ) { $selected = `keyframe -q -n -sl`; } else if ( $tipoDiSelezione == 1 ) { $selected = `ls -sl`; } $startTime = `findKeyframe -which first $selected`; $endTime = `findKeyframe -which last $selected`; intSliderGrp -e -en false -v $startTime startTimeSlider; intSliderGrp -e -en false -v $endTime endTimeSlider; checkBox -e -en false chk1; } else { $startTime = $laststartTime; $endTime = $lastEndTime; intSliderGrp -e -en true -v $startTime startTimeSlider; intSliderGrp -e -en true -v $endTime endTimeSlider; checkBox -e -en true chk1; } } // global proc checkTimeS3() { if (`checkBox -q -v chk3`) { intField -e -en true times; intField -e -en false toFrame; checkBox -e -v false chk4; } else { intField -e -en false times; } } global proc checkTimeS4() { if (`checkBox -q -v chk4`) { intField -e -en true toFrame; intField -e -en false times; checkBox -e -v false chk3; } else { intField -e -en false toFrame; } } //reset global proc doReset() { global string $tipoDiSelezione; global string $selected[]; global int $startTime; global int $endTime; global int $laststartTime; global int $lastEndTime; $startTime = $laststartTime = 1; $endTime = $lastEndTime = 100; intField -edit -v 1 times; intSliderGrp -edit -v 1 -en true startTimeSlider; intSliderGrp -edit -v 100 -en true endTimeSlider; checkBox -edit -v false -en true chk1; checkBox -edit -v false -en true chk2; select -clear; } //main global proc cycle() { //set the vars global string $tipoDiSelezione; global string $selected[]; global string $object; global int $times; global int $startFrame; global int $endFrame; //get the selection's kind,object or animation curves (1 = obj, 2 = curves) $tipoDiSelezione= `radioButtonGrp -q -sl tipoDiSelezione`; if ( $tipoDiSelezione == 2 ) { $selected = `keyframe -q -n -sl`; } else if ( $tipoDiSelezione == 1 ) { $selected = `ls -sl`; } $startFrame = `intSliderGrp -q -v startTimeSlider`; $endFrame = `intSliderGrp -q -v endTimeSlider`; //build the time var $tempo = $startFrame + ":" + $endFrame; //get how many times I have to cycle the animation if (`checkBox -q -v chk3`) { $times = `intField -q -v times`; } else if (`checkBox -q -v chk4`) { //animation's end int $fine = `intField -q -v toFrame`; int $durataTotale = $fine - $startFrame; //cycle duration int $durataCiclo = $endFrame - $startFrame; $times = ceil($durataTotale/$durataCiclo); } //copy int $numberOfCurves = `copyKey -time $tempo -option curve $selected`; //...and paste pasteKey -time $endFrame -float $endFrame -option insert -copies $times -connect 1 -timeOffset 0 -floatOffset 0 -valueOffset 0 $selected; //print some infos int $newEndAnimation = `findKeyframe -which last $selected`; print ($numberOfCurves + " curve(s) cycled , animation's last frame is " + $newEndAnimation); } //UI global proc alienCycle() { if (`window -ex alienCycle`) deleteUI alienCycle; window -title "Alien Cycle" alienCycle; formLayout rcl1; separator -style "in" sep1; radioButtonGrp -nrb 2 -l "What's your selection?" -l1 "Object" -l2 "Curves"-sl 1 tipoDiSelezione; separator -style "in" sep2; intSliderGrp -l "Start Time: " -cc fldTimeS -f true -min -10000 -max 10000 startTimeSlider; intSliderGrp -l "End Time: " -cc fldTimeE -f true -min -10000 -max 10000 endTimeSlider; checkBox -l "Use Time Slider" -cc checkTimeS1 -v false chk1; checkBox -l "Whole Animation" -cc checkTimeS2 -v false chk2; separator -style "in" sep3; checkBox -l "how many times?" -cc checkTimeS3 -v true chk3; intField -value 1 -minValue 1 -maxValue 1000 times; checkBox -l "cycle to this frame" -cc checkTimeS4 -v false chk4; intField -en false -value 1 toFrame; separator -style "in" sep4; button -l "Cycle" -align "center" -c cycle -w 60 but1; button -l "Reset" -align "center" -c doReset -w 60 but2; button -l "Exit" -align "center" -c "evalDeferred \"deleteUI alienCycle\";" -w 60 but3; formLayout -e -af sep1 "left" 0 -af sep1 "top" 10 -af sep1 "right" 0 -af tipoDiSelezione "left" 0 -ac tipoDiSelezione "top" 4 sep1 -af sep2 "left" 0 -ac sep2 "top" 4 tipoDiSelezione -af sep2 "right" 0 -af startTimeSlider "left" 0 -ac startTimeSlider "top" 4 sep2 -af endTimeSlider "left" 0 -ac endTimeSlider "top" 4 startTimeSlider -af chk1 "left" 0 -ac chk1 "top" 4 endTimeSlider -af chk2 "left" 0 -ac chk2 "top" 4 chk1 -af sep3 "left" 0 -ac sep3 "top" 4 chk2 -af sep3 "right" 0 -af chk3 "left" 0 -ac chk3 "top" 4 sep3 -ac times "left" 20 chk3 -ac times "top" 4 sep3 -af chk4 "left" 0 -ac chk4 "top" 4 chk3 -ac toFrame "left" 16 chk4 -ac toFrame"top" 4 chk3 -af sep4 "left" 0 -ac sep4 "top" 4 toFrame -af sep4 "right" 0 -af but1 "left" 0 -ac but1 "top" 4 sep4 -ac but2 "left" 50 but1 -ac but2 "top" 4 sep4 -ac but3 "left" 50 but2 -ac but3 "top" 4 sep4 rcl1; doReset(); showWindow alienCycle; }