/* This file downloaded from Highend3d.com '' '' Highend3d.com File Information: '' '' Script Name: Crop Animation '' Author: daagom '' Last Updated: Nov 01, 2006 '' Update/Change this file at: '' http://Highend3d.com/maya/downloads/mel_scripts/animation/887.html '' '' Please do not alter any information above this line '' it is generated dynamically by Highend3d.com and will '' be changed automatically on any updates. */ /* '' Author: Jeremiah Grant '' Title: unprefixHierarchy.mel '' '' Description: Crops your animation based on where the timeslider is set. '' i.e. If the full animation range is frames 0 - 1000 and you only have animation '' from frames 20 - 200, move your playback time to 20 - 200. The script will crop '' all animation before and after it and move keys so the animation starts at frame 0. '' '' You can email me at jeremiah@jeremiahgrant.com '' Website: www.jeremiahgrant.com */ proc cropAnim() { $animMin = `playbackOptions -q -ast`; $animMax = `playbackOptions -q -aet`; $min = `playbackOptions -q -min`; $max = `playbackOptions -q -max`; $diff = $animMin - $min; // print $diff; $objects = `ls -tr`; for( $obj in $objects ) { string $buff[], $attrBuff[]; $numKeys = `keyframe -q -kc $obj`; if( $numKeys > 1 ) { string $allAttr[] = `listAttr -k $obj`; for( $attr in $allAttr ) { $numKeyFrames = `keyframe -at $attr -q -keyframeCount $obj`; // print $numKeyFrames; // print (" " + $obj + " " + $attr + "\n"); if ($numKeyFrames > 0) { $animMax = `findKeyframe -w last ($obj+"."+$attr)`; tokenize $attr "." $attrBuff; if(`size($attrBuff[1])` > 0) continue; else if( `keyframe -query -keyframeCount ($obj+"."+$attr)` ) { currentTime $min; setKeyframe ($obj + "." + $attr); currentTime $max; setKeyframe ($obj + "." + $attr); } if( $max != $animMax ) { selectKey -time ( ($max+1) + ":" + ($animMax+1) ) -at $attr $obj; cutKey -animation keys -clear; } if( $min != $animMin ) { selectKey -time ( $animMin + ":" + ($min-1) ) -at $attr $obj; cutKey -animation keys -clear; keyframe -e -r -o over -tc $diff ($obj + "_" + $attr) ; } } } } } playbackOptions -min 0 -max ($max+$diff) ; } cropAnim;