// =========================================================================== // 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: // doCopyKeyArgList is the actual proc that is executed from the // Edit->Keys->Copy Keys option box or menu. // // doCopyKeyArgList allows for a variable number // or arguments to be passed in through a string array. // This is not possible through the fixed-arg proc doCopyKey // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $whichRange, $timeRange, $option, $hierarchy, // $doControlPoints, $doShapes, $useChannelBox, // $selectionConnection // "2" : $options // // $args // Version 1 // [0] $whichRange 1 : time range all // 2 : use playback range // 3 : use $timeRange // [1] $timeRange startTime:endTime // [2] $option keys // curve // [3] $hierarchy 1 : none // 2 : below // [4] $doControlPoints 0 / 1 // [5] $doShapes 0 / 1 // [6] $useChannelBox 0 / 1 // [7] $selectionConnection name of selection connection to use // unless $options has "bufferCurve" in which // case this is the name of the editor // Version 2 // [8] $options a ':' delimited list of options // noOptions an empty placeholder // bufferCurve create buffer curves // Version 3 // [11] $fromGraphEditor 0 / 1 // [12] $doDrivenChannels 0 / 1 // // Return Value: // The number of curves from which keys were copied. // global proc int doCopyKeyArgList( string $version, string $args[] ) { int $versionNum = $version; int $whichRange = $args[0]; string $timeRange = $args[1]; string $option = $args[2]; string $hierarchy = $args[3]; int $doControlPoints = $args[4]; int $doShapes = $args[5]; int $useChannelBox = $args[6]; string $selectionConnection = $args[7]; string $options = ($versionNum >= 2 ? $args[8] : "noOptions"); int $fromGraphEditor = $versionNum >= 3 ? $args[9] : "1"; int $doDriven = $versionNum >= 3 ? $args[10] : "1"; string $cmd = "copyKey "; 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); int $needOption = true; if( $whichRange == 1 ) { $timeRange = ":"; $needOption = false; } else if( $whichRange == 2 ) { $timeRange = ( `playbackOptions -q -min` + ":" + `playbackOptions -q -max` ); } // 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. // int $keys = `keyframe -sl -q -kc`; // Special cmd if called from the graph editor // (not the option box). // if ($fromGraphEditor == 2) { string $currentPanel = `getPanel -withFocus`; string $dopeSheet = $currentPanel + "DopeSheetEd"; float $region[] = `dopeSheetEditor -q -sel $dopeSheet`; if ($region[0] < $region[1]) { // We have a well defined manip region $timeRange = ( $region[0] + ":" + $region[1] ); } // Add the time range $cmd = ( $cmd + "-time \"" + $timeRange + "\" " ); // If there's a time specified, always add the option if ($region[0] < $region[1]) { $cmd = ( $cmd + "-option area " ); } else if( $needOption ) { $cmd = ( $cmd + "-option " + $option + " " ); } } else if( !$fromGraphEditor || ( $keys == 0 ) || $option != "keys") { $cmd = ( $cmd + "-time \"" + $timeRange + "\" " ); if( $fromGraphEditor || $doDriven ) { $cmd = ( $cmd + "-float \"" + $timeRange + "\" " ); } // If there's a time specified, always add the option // if( $needOption ) { $cmd = ( $cmd + "-option " + $option + " " ); } } if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) { string $syntax[] = keySetOptionBoxCommon( { "copyKey", "unknown", "channelBoxSyntax" } ); if( size( $syntax[0] ) == 0 ) { $cmd = ""; warning( (uiRes("m_doCopyKeyArgList.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. // The dopeSheet needs to be able to handle this case. // if( $keys == 0 || $fromGraphEditor != 1 || $option != "keys" ) { if ($members == "{}") { $cmd = ""; warning ( (uiRes("m_doCopyKeyArgList.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 ); } }