// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: 10 Aug 98 // // Description: // doScaleKeyArgList is the actual proc that is executed from the // Edit->Keys->Scale Keys option box or menu // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $whichRange, $timeRange, $whichMethod, $newStartTime, // $newEndTime, $timeScale, $timePivot, $valueScale, // $valuePivot, $hierarchy, $doControlPoints, $doShapes, // $useChannelBox, $useAllAnimCurves, $selectionConnection // $scaleSpecifiedKeys // "2" : $options // // $args // Version 1 // [0] $whichRange 1 : time range all // 2 : use playback range // 3 : use $timeRange // [1] $timeRange startTime:endTime // [2] $whichMethod 1 : pivot based scaling // 2 : newStartTime:newEndTime scaling // [3] $newStartTime // [4] $newEndTime // [5] $timeScale // [6] $timePivot // [7] $valueScale // [8] $valuePivot // [9] $hierarchy 1 : none // 2 : below // [10] $doControlPoints 0 / 1 // [11] $doShapes 0 / 1 // [12] $useChannelBox 0 / 1 // [13] $useAllAnimCurves 0 / 1 // [14] $selectionConnection name of selection connection to use // unless $options has "bufferCurve" in which // case this is the name of the editor // [15] $scaleSpecifiedKeys 0 / 1 // Version 2 // [16] $options a ':' delimited list of options // noOptions an empty placeholder // bufferCurve create buffer curves // // Version 3 // [17] $fromGraphEditor 0 / 1 // [18] $doDrivenChannels 0 / 1 // // Return Value: // The number of curves which were scaled. // global proc int doScaleKeyArgList( string $version, string $args[] ) { int $versionNum = $version; int $whichRange = $args[0]; string $timeRange = $args[1]; int $whichMethod = $args[2]; float $newStartTime = $args[3]; float $newEndTime = $args[4]; float $timeScale = $args[5]; float $timePivot = $args[6]; float $valueScale = $args[7]; float $valuePivot = $args[8]; string $hierarchy = $args[9]; int $doControlPoints = $args[10]; int $doShapes = $args[11]; int $useChannelBox = $args[12]; int $useAllAnimCurves = $args[13]; string $selectionConnection = $args[14]; int $scaleSpecifiedKeys = $args[15]; string $options = ($versionNum >= 2 ? $args[16] : "noOptions"); int $fromGraphEditor = $versionNum >= 3 ? $args[17] : 1; int $doDrivenKeys = $versionNum >= 3 ? $args[18] : 1; string $cmd = "scaleKey "; // Set the scale specified key flag. // $cmd += ("-scaleSpecifiedKeys " + $scaleSpecifiedKeys + " "); string $realConnection = $selectionConnection; // Check for the bufferCurve option // if (match ("bufferCurve", $options) == "bufferCurve") { $realConnection = `editor -query -mainListConnection $selectionConnection`; // Check to see if we need to create buffer curves // if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") { $cmd = "bufferCurve -animation \"keys\" -overwrite false; " + $cmd; } } // Get the target objects // string $members = expandSelectionConnection ($realConnection); if( $whichRange == 1 ) { $timeRange = ":"; } else if( $whichRange == 2 ) { $timeRange = ( `playbackOptions -q -min` + ":" + `playbackOptions -q -max` ); } int $keys = `keyframe -sl -q -kc`; if( !$fromGraphEditor || ( $keys == 0 ) ) { $cmd = ( $cmd + "-time \"" + $timeRange + "\" " ); if( $fromGraphEditor || $doDrivenKeys ) { $cmd = ( $cmd + "-float \"" + $timeRange + "\" " ); } } if ($whichMethod == 1) { $cmd += "-timeScale " + $timeScale; $cmd += " -timePivot " + $timePivot; $cmd += " -floatScale " + $timeScale; $cmd += " -floatPivot " + $timePivot; $cmd += " -valueScale " + $valueScale; $cmd += " -valuePivot " + $valuePivot + " "; } else { $cmd += "-newStartTime " + $newStartTime; $cmd += " -newStartFloat " + $newStartTime; $cmd += " -newEndTime " + $newEndTime; $cmd += " -newEndFloat " + $newEndTime + " "; } if( $useAllAnimCurves ) { int $i; string $curves[] = `ls -type animCurveTL`; for( $i = 0; $i < size( $curves ); $i++ ) { $cmd = ( $cmd + " " + $curves[$i] ); } $curves = `ls -type animCurveTU`; for( $i = 0; $i < size( $curves ); $i++ ) { $cmd = ( $cmd + " " + $curves[$i] ); } $curves = `ls -type animCurveTA`; for( $i = 0; $i < size( $curves ); $i++ ) { $cmd = ( $cmd + " " + $curves[$i] ); } $curves = `ls -type animCurveTT`; for( $i = 0; $i < size( $curves ); $i++ ) { $cmd = ( $cmd + " " + $curves[$i] ); } } else if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) { string $syntax[] = keySetOptionBoxCommon( { "scaleKey", "unknown", "channelBoxSyntax" } ); if( size( $syntax[0] ) == 0 ) { $cmd = ""; warning( (uiRes("m_doScaleKeyArgList.kNoChannelsSelected")) ); } else { $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " ); $cmd = $cmd + $syntax[0]; } } else if( $members != "" ) { // Only add the selection connection to the cmd if // there are NO active keys (in the graph editor), // or we're not called from the graphEditor. // int $keys = `keyframe -sl -q -kc`; if( $keys == 0 || !$fromGraphEditor ) { if ($members == "{}") { $cmd = ""; warning ( (uiRes("m_doScaleKeyArgList.kNoObjectsSelected")) ); } else { $cmd = ($cmd + "-hierarchy " + $hierarchy + " " + "-controlPoints " + $doControlPoints + " " + "-shape " + $doShapes + " " + $members); } } } else { $cmd = ( $cmd + "-animation objects " + "-hierarchy " + $hierarchy + " " + "-controlPoints " + $doControlPoints + " " + "-shape " + $doShapes + " " ); } if( $cmd == "" ) { return 0; } else { return evalEcho( $cmd ); } }