/* Snap Keyframe to Current Time (Retain Spacing) - dpMoveSelectedKeys.mel - By David Peers (davidp@al.com.au) for info see www.andrewsilke.com/mel_info.html 29-3-04 WHAT IT DOES Script to move selected keys to current frame, keeping relative positions HOW TO INSTALL 1. Copy the mel file to a directory on your scripts path eg. documents path \maya\5.0\scripts 2. map the following to a hotkey or shelf button: dpMoveSelectedKeys; HOW TO USE 1. Press the hotkey or shelf button to run script */ global proc dpMoveSelectedKeys () { // Get current time int $currentTime = `currentTime -q`; // Find and store selected key set (stores frame numbers) float $selectedKeys[] = `keyframe -query -selected`; float $sortedKeys[] = `sort $selectedKeys`; float $firstKey = $sortedKeys[0]; // Find difference between // CurrentTime - first key float $offset = $currentTime - $firstKey; // Move all keys by this amount string $selCurves[] = `keyframe -query -name -sl`; float $keyTimes[]; for( $curve in $selCurves ) { clear $keyTimes; $keyTimes = `keyframe -sl -q -tc $curve`; for($time in $keyTimes ) { keyframe -e -iub true -r -o over -tc $offset -t $time $curve ; } } }