// =========================================================================== // 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: // doPasteKeyArgList is the actual proc that is executed from the // Edit->Keys->Paste Keys option box or menu // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $timeRange, $copies, $whichTime, $option, $connect, // $selectionConnection // "2" : $options // "3" : $fromGraphEditor // "4" : $timeOffset, $valueOffset // "5" : $timeRangeOverride // // $args // Version 1 // [0] $timeRange startTime:endTime // [1] $copies // [2] $whichTime 1 : startTime // 2 : startTime : endTime // 3 : currentTime // 4 : clipboard time // [3] $option scale // scaleInsert // scaleReplace // scaleReplaceCompletely // scaleMerge // fit // fitInsert // fitReplace // fitReplaceCompletely // fitMerge // insert // replace // replaceCompletely // merge // [4] $connect 0 / 1 // [5] $selectionConnection name of selection connection to use // unless $options has "bufferCurve" in which // case this is the name of the editor // Version 2 // [6] $options a ':' delimited list of options // noOptions an empty placeholder // bufferCurve create buffer curves // Version 3 // [7] $fromGraphEditor true if this is being called from the // graph editor or dope sheet // Version 4 // [8] $timeOffset amount to offset pasted keys in time // [9] $valueOffset amount to offset pasted keys in value // // Version 5 // [10] $timeRangeOverride selected keys override specified timeRange? // // Return Value: // The number of curves to which keys were pasted. // global proc int doPasteKeyArgList( string $version, string $args[] ) { int $versionNum = $version; string $timeRange = $args[0]; int $copies = $args[1]; int $whichTime = $args[2]; string $option = $args[3]; int $connect = $args[4]; string $selectionConnection = $args[5]; string $options = ($versionNum >= 2 ? $args[6] : "noOptions"); int $fromGraphEditor = ($versionNum >= 3 ? $args[7] : $selectionConnection != ""); float $timeOffset = ($versionNum >= 4 ? $args[8] : 0); float $valueOffset = ($versionNum >= 4 ? $args[9] : 0); int $timeRangeOverride = ($versionNum >= 5 ? $args[10] : true); string $cmd = "pasteKey"; 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( ($members == "") && !$fromGraphEditor ) { $cmd = $cmd + " -animation objects"; } // Check to see if a time range has been specified // int $keys = 0; catch ($keys = `keyframe -animation keys -query -keyframeCount`); int $timeRangeSet = false; if ($fromGraphEditor == 2) { string $currentPanel = `getPanel -withFocus`; string $dopeSheet = $currentPanel + "DopeSheetEd"; float $region[] = `dopeSheetEditor -q -sel $dopeSheet`; if ($region[0] < $region[1]) { $cmd = ($cmd + " -time " + $region[0]); $cmd = ($cmd + " -float " + $region[0]); $option = "insert"; $timeRangeSet = true; } } else if ($fromGraphEditor && $timeRangeOverride) { // Check to see if keys have been selected // if ($keys != 0) { float $selectedTimes[] = `keyframe -query -timeChange`; $startTime = $selectedTimes[0]; $endTime = $startTime; // Most of the other options make no sense, and some require // time ranges that may or may not be available, given that // the time range is now determined by active keys. // $option = "insert"; for ($time in $selectedTimes) { $startTime = min ($startTime, $time); $endTime = max ($endTime, $time); } if ($startTime == $endTime) { $cmd = ($cmd + " -time " + $startTime); $cmd = ($cmd + " -float " + $startTime); } else { $cmd = ($cmd + " -time \"" + $startTime + ":" + $endTime + "\""); $cmd = ($cmd + " -float \"" + $startTime + ":" + $endTime + "\""); // Change the paste option to scaleReplace // $option = "scaleReplace"; } $timeRangeSet = true; } } if( !$timeRangeSet && ( $whichTime != 4 ) ) { string $range[]; tokenize ($timeRange, ":", $range); // There must be two times, given the way we set up // the option var earlier. // string $rangeForCommand; if(( $whichTime == 1 ) && ( size( $range ) > 0 )) { $rangeForCommand = $range[0]; } else if(( $whichTime == 2 ) && ( size( $timeRange ) > 1 )) { $rangeForCommand = ( "\"" + $timeRange + "\"" ); } else { $rangeForCommand = `currentTime -query`; } $cmd = ( $cmd + " -time " + $rangeForCommand ); $cmd = ( $cmd + " -float " + $rangeForCommand ); } $cmd = ( $cmd + " -option " + $option ); $cmd = ( $cmd + " -copies " + $copies ); $cmd = ( $cmd + " -connect " + $connect ); $cmd = ( $cmd + " -timeOffset " + $timeOffset + " -floatOffset " + $timeOffset ); $cmd = ( $cmd + " -valueOffset " + $valueOffset ); if( $members != "" ) { if ($keys == 0 || $fromGraphEditor != 1 ) { if ($members == "{}") { if(size(`ls -sl`) == 0){ //selected at least one object as target $cmd = ""; warning ( (uiRes("m_doPasteKeyArgList.kNoObjectsSelected")) ); } } else { $cmd = ($cmd + " " + $members); } } } if( $cmd == "" ) { return 0; } else { return evalEcho( $cmd ); } }