// =========================================================================== // 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: // doSnapKeyArgList is the actual proc that is executed from the // Edit->Keys->Snap Keys option box or menu // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $allAnimCurves, $hierarchy, $useChannelBox, // $doControlPoints, $doShapes, // $whichRange, $timeRange, $doSnap, // $snapMultiple, $doSelectAfterSnap, // $selectionConnection, $options // // $args // Version 1 // [0] $allAnimCurves 0 / 1 // [1] $hierarchy 1 : none // 2 : below // [2] $useChannelBox 0 / 1 // [3] $doDriven 0 / 1 // [4] $doControlPoints 0 / 1 // [5] $doShapes 0 / 1 // [6] $whichRange 1 : time range all // 2 : use playback range // 3 : use $timeRange // [7] $timeRange startTime:endTime // [8] $snapTimes 0 / 1 // [9] $snapValues 0 / 1 // [10] $timeMultiple snapped key times a multiple of this value // [11] $valueMultiple snapped key values a multiple of this value // [12] $selectionConnection name of selection connection to use // unless $options has "bufferCurve" in which // case this is the name of the editor // [13] $options a ':' delimited list of options // noOptions: an empty placeholder // bufferCurve: create buffer curves // [14] $doSelectNotSnap issue a selectKey cmd to select unsnapped // keys based on these option settings // [15] $fromGraphEditor 0 / 1 // // // Return Value: // The number of curves from which keys were cut. // global proc int doSnapKeyArgList( string $version, string $args[] ) { int $versionNum = $version; int $allAnimCurves = $args[0]; string $hierarchy = $args[1]; int $useChannelBox = $args[2]; int $doDriven = $args[3]; int $doControlPoints = $args[4]; int $doShapes = $args[5]; int $whichRange = $args[6]; string $timeRange = $args[7]; int $snapTime = $args[8]; int $snapValue = $args[9]; float $timeMultiple = $args[10]; float $valueMultiple = $args[11]; int $doSelectNotSnap = $args[12]; string $selectionConnection = $args[13]; string $options = $args[14]; int $fromGraphEditor = $args[15]; string $cmd = "snapKey "; string $realConnection = $selectionConnection; // Check for the bufferCurve option. Need the "exists" check because // the "editor" doesn't exist for calls from the Dope Sheet. // if(( match ("bufferCurve", $options) == "bufferCurve" ) && ( `editor -exists $selectionConnection` )) { $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); string $baseCmd = ""; // Check to see if a time range has been specified. If no time range, // then we don't add the option, since we're doing all the keyframes // and an option makes no sense. // if( $whichRange == 1 ) { $timeRange = ":"; } else if( $whichRange == 2 ) { $timeRange = ( `playbackOptions -q -min` + ":" + `playbackOptions -q -max` ); } int $keys = `keyframe -q -sl -kc`; if( !$fromGraphEditor || ( $keys == 0 ) ) { // Only add the -t flag if there are no keys active // OR this option box was invoked from main menu. // if(($keys == 0) || ($members == "")) { $baseCmd = ( $baseCmd + "-time \"" + $timeRange + "\" " ); if( $fromGraphEditor || $doDriven ) { $baseCmd = ( $baseCmd + "-float \"" + $timeRange + "\" " ); } } } if( $snapTime ) { $cmd = ( $cmd + "-timeMultiple " + $timeMultiple + " " ); } if( $snapValue ) { $cmd = ( $cmd + "-valueMultiple " + $valueMultiple + " " ); } if( $doSelectNotSnap ) { $cmd = ( "selectKey -unsnappedKeys " + $timeMultiple + " " ); } if( !$fromGraphEditor && $allAnimCurves ) { int $i; string $curves[] = `ls -type animCurveTL`; for( $i = 0; $i < size( $curves ); $i++ ) { $baseCmd = ( $baseCmd + " " + $curves[$i] ); } $curves = `ls -type animCurveTU`; for( $i = 0; $i < size( $curves ); $i++ ) { $baseCmd = ( $baseCmd + " " + $curves[$i] ); } $curves = `ls -type animCurveTA`; for( $i = 0; $i < size( $curves ); $i++ ) { $baseCmd = ( $baseCmd + " " + $curves[$i] ); } $curves = `ls -type animCurveTT`; for( $i = 0; $i < size( $curves ); $i++ ) { $baseCmd = ( $baseCmd + " " + $curves[$i] ); } } else if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) { string $syntax[] = keySetOptionBoxCommon( { "snapKey", "unknown", "channelBoxSyntax" } ); if( size( $syntax[0] ) == 0 ) { $baseCmd = ""; warning( (uiRes("m_doSnapKeyArgList.kNoChannelsSelected")) ); } else { $baseCmd = ( $baseCmd + "-hierarchy " + $hierarchy + " " ); $baseCmd = $baseCmd + $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. // if( $keys == 0 || !$fromGraphEditor ) { if( $members == "{}" ) { $baseCmd = ""; warning( (uiRes("m_doSnapKeyArgList.kNoObjectsSelected")) ); } else { $baseCmd = ( $baseCmd + "-hierarchy " + $hierarchy + " " + "-controlPoints " + $doControlPoints + " " + "-shape " + $doShapes + " " + $members ); } } } else { $baseCmd = ( $baseCmd + "-animation objects " + "-hierarchy " + $hierarchy + " " + "-controlPoints " + $doControlPoints + " " + "-shape " + $doShapes + " " ); } // If there are active keys, $baseCmd is appropriately empty... // if(( $baseCmd != "" ) || ( $keys > 0 )) { $cmd = ( $cmd + $baseCmd + "; "); return evalEcho( $cmd ); } else { return 0; } }