// =========================================================================== // 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: Oct. 31/97 // // Description: // doSimplifyArgList is the actual proc that is executed from the // Edit->Curves->Simplify option box or menu // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $timeRange, $timeTolerance, $valueTolerance, // $selectionConnection, $options // // $args // Version 1 // [0] $whichRange 1: time range all // 2: use playback range // 3: use $timeRange // [1] $timeRange startTime:endTime // [2] $timeTolerance // [3] $valueTolerance // [4] $selectionConnection name of selection connection to use // unless $options has "bufferCurve" in which // case this is the name of the editor // [5] $options a ':' delimited list of options // noOptions an empty placeholder // bufferCurve create buffer curves // [6] $method 1: Classic // 2: Dense Data // // Return Value: // The number of curves simplified. // global proc int doSimplifyArgList (string $version, string $args[]) { int $versionNum = $version; int $whichRange = $args[0]; string $timeRange = $args[1]; float $timeTolerance = $args[2]; float $valueTolerance = $args[3]; string $selectionConnection = $args[4]; string $options = $args[5]; int $method = $args[6]; string $cmd = "simplify "; if ($method == 2) { $cmd = "filterCurve -f simplify "; } 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; int $keyCount = 0; if( $method == 2) { // Get the target objects // $members = expandSelectionConnection ($realConnection); if ($whichRange > 1) { float $startTime = `playbackOptions -q -min`; float $endTime = `playbackOptions -q -max`; if ($whichRange == 3) { string $buff[]; tokenize $timeRange ":" $buff; $startTime = $buff[0]; $endTime = $buff[1]; } $cmd = ( $cmd + "-startTime \"" + $startTime + "\" " ); $cmd = ( $cmd + "-endTime \"" + $endTime + "\" " ); } } else { // Not supported for non-classic simplification. $members = expandSelectionConnection ($realConnection); // Check to see if a time range has been specified // int $keyCount = `keyframe -sl -q -kc`; // Only add the -time flag if no keys are active. // No time range means leave off the -t flag and // do the whole curve. // if( $whichRange == 1 ) { $timeRange = ":"; } else if( $whichRange == 2 ) { $timeRange = ( `playbackOptions -q -min` + ":" + `playbackOptions -q -max` ); } if ($keyCount == 0) { $cmd = ( $cmd + "-time \"" + $timeRange + "\" " ); $cmd = ( $cmd + "-float \"" + $timeRange + "\" " ); } } // Add on the tolerances // $cmd = $cmd + "-timeTolerance " + $timeTolerance + " "; if ($method != 2) { $cmd += ("-floatTolerance " + $timeTolerance + " " + "-valueTolerance " + $valueTolerance); } // Add the selection connection to the cmd if there are no keyframes // on the active list. // if ($keyCount == 0) { if (($members == "") || ($members == "{}")) { $cmd = ""; warning ( (uiRes("m_doSimplifyArgList.kNoObjectsSelected")) ); } else { $cmd = ($cmd + " " + $members); } } if ($cmd == "") { return (0); } else { return evalEcho( $cmd ); } }