// =========================================================================== // 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: 24 January 2006 // // Description: // This is a helper script to perform the "cacheFile -replace" command // using the corresponding option box values. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { // Time range // if( $forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesTimeRange`) { optionVar -intValue replaceGeometryCacheFramesTimeRange 1; } // startTime // if ($forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesStartTime`) { optionVar -floatValue replacenClothCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesEndTime`) { optionVar -floatValue replaceGeometryCacheFramesEndTime 10.0; } // Interpolation type // if( $forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesInterpType`) { optionVar -intValue replaceGeometryCacheFramesInterpType 1; } // interpolation startTime // if ($forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesInterpStartTime`) { optionVar -floatValue replaceGeometryCacheFramesInterpStartTime 1.0; } // Interpolation endTime // if ($forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesInterpEndTime`) { optionVar -floatValue replaceGeometryCacheFramesInterpEndTime 10.0; } // Interpolated frames rename string // if ($forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesInterpRename`) { optionVar -stringValue replaceGeometryCacheFramesInterpRename "backup"; } // In-tangent // if ($forceFactorySettings || !`optionVar -exists repGeomCacheFramesInTan`) { // 1 == linear optionVar -intValue repGeomCacheFramesInTan 1; } // Out-tangent // if ($forceFactorySettings || !`optionVar -exists repGeomCacheFramesOutTan`) { // 1 == linear optionVar -intValue repGeomCacheFramesOutTan 1; } // delete old unused string prefs if they are lingering around // if (`optionVar -exists replaceGeometryCacheFramesInTangent`) { optionvar -rm replaceGeometryCacheFramesInTangent; } if (`optionVar -exists replaceGeometryCacheFramesOutTangent`) { optionvar -rm replaceGeometryCacheFramesOutTangent; } // simulation rate // if ($forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesSimulationRate`) { optionVar -floatValue replaceGeometryCacheFramesSimulationRate 1; } // sampling rate // if( $forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesSampleMultiplier` ) { optionVar -intValue replaceGeometryCacheFramesSampleMultiplier 1; } // Delete backup files // if( $forceFactorySettings || !`optionVar -exists replaceGeometryCacheFramesNoBackups` ) { optionVar -intValue replaceGeometryCacheFramesNoBackups 0; } } // // Procedure Name: // replaceGeometryCacheFramesEnabling // // Description: // Set the enable state of start and end time fields. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that object names of the fields can be // successfully resolved. // // state - Enable state of the fields. // // Return Value: // None. // global proc replaceGeometryCacheFramesEnabling() { int $startEnd = ( `radioButtonGrp -q -sl replaceGeometryCacheFramesTimeRange2` == 1 ); floatFieldGrp -edit -enable $startEnd replaceGeometryCacheFramesReplaceStart; floatFieldGrp -edit -enable $startEnd replaceGeometryCacheFramesReplaceEnd; floatFieldGrp -edit -enable $startEnd replaceGeometryCacheFramesSimulationRate; intFieldGrp -edit -enable $startEnd replaceGeometryCacheFramesSampleMultiplier; int $interp = ( `radioButtonGrp -q -sl replaceGeometryCacheFramesInterpType1` == 0 ); floatFieldGrp -edit -enable $interp replaceGeometryCacheFramesInterpStart; floatFieldGrp -edit -enable $interp replaceGeometryCacheFramesInterpEnd; optionMenuGrp -edit -enable $interp replaceGeometryCacheFramesInTangent; optionMenuGrp -edit -enable $interp replaceGeometryCacheFramesOutTangent; int $rename = ( `radioButtonGrp -q -sl replaceGeometryCacheFramesInterpType3` == 1 ); textFieldGrp -edit -enable $rename replaceGeometryCacheFramesInterpFilename; } // // Procedure Name: // replaceGeometryCacheFramesSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc replaceGeometryCacheFramesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query replaceGeometryCacheFramesTimeRange`; eval( "radioButtonGrp -e -select 1 replaceGeometryCacheFramesTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query replaceGeometryCacheFramesStartTime`; float $endTime = `optionVar -query replaceGeometryCacheFramesEndTime`; floatFieldGrp -edit -value1 $startTime replaceGeometryCacheFramesReplaceStart; floatFieldGrp -edit -value1 $endTime replaceGeometryCacheFramesReplaceEnd; // Interpolation // int $interpType = `optionVar -q replaceGeometryCacheFramesInterpType`; eval( "radioButtonGrp -e -sl 1 replaceGeometryCacheFramesInterpType" + $interpType); float $interpStart = `optionVar -query replaceGeometryCacheFramesInterpStartTime`; float $interpEnd = `optionVar -query replaceGeometryCacheFramesInterpEndTime`; floatFieldGrp -edit -value1 $interpStart replaceGeometryCacheFramesInterpStart; floatFieldGrp -edit -value1 $interpEnd replaceGeometryCacheFramesInterpEnd; int $inTangent = `optionVar -query repGeomCacheFramesInTan`; int $outTangent = `optionVar -query repGeomCacheFramesOutTan`; optionMenuGrp -edit -sl $inTangent replaceGeometryCacheFramesInTangent; optionMenuGrp -edit -sl $outTangent replaceGeometryCacheFramesOutTangent; string $rename = `optionVar -query replaceGeometryCacheFramesInterpRename`; textFieldGrp -edit -text $rename replaceGeometryCacheFramesInterpFilename; // Sampling information // float $simulation = `optionVar -q replaceGeometryCacheFramesSimulationRate` ; floatFieldGrp -e -v1 $simulation replaceGeometryCacheFramesSimulationRate ; int $samplingRate = `optionVar -q replaceGeometryCacheFramesSampleMultiplier` ; intFieldGrp -edit -v1 $samplingRate replaceGeometryCacheFramesSampleMultiplier ; int $noBackups = `optionVar -query replaceGeometryCacheFramesNoBackups`; checkBoxGrp -e -v1 $noBackups replaceGeometryCacheFramesDeleteBackups; replaceGeometryCacheFramesEnabling(); } // // Procedure Name: // replaceGeometryCacheFramesCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc replaceGeometryCacheFramesCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 1; if( `radioButtonGrp -q -sl replaceGeometryCacheFramesTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl replaceGeometryCacheFramesTimeRange2` ) { $timeRangeMode = 2; } optionVar -intValue replaceGeometryCacheFramesTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue replaceGeometryCacheFramesStartTime `floatFieldGrp -query -value1 replaceGeometryCacheFramesReplaceStart`; optionVar -floatValue replaceGeometryCacheFramesEndTime `floatFieldGrp -query -value1 replaceGeometryCacheFramesReplaceEnd`; // Interpolation type // int $interpType; if( `radioButtonGrp -q -sl replaceGeometryCacheFramesInterpType1` ) { $interpType = 1; } else if( `radioButtonGrp -q -sl replaceGeometryCacheFramesInterpType2` ) { $interpType = 2; } else if( `radioButtonGrp -q -sl replaceGeometryCacheFramesInterpType3` ) { $interpType = 3; } optionVar -intValue replaceGeometryCacheFramesInterpType $interpType; // Interpolation start/end // optionVar -floatValue replaceGeometryCacheFramesInterpStartTime `floatFieldGrp -q -v1 replaceGeometryCacheFramesInterpStart`; optionVar -floatValue replaceGeometryCacheFramesInterpEndTime `floatFieldGrp -q -v1 replaceGeometryCacheFramesInterpEnd`; // In/Out tangents optionVar -intValue repGeomCacheFramesInTan `optionMenuGrp -q -sl replaceGeometryCacheFramesInTangent`; optionVar -intValue repGeomCacheFramesOutTan `optionMenuGrp -q -sl replaceGeometryCacheFramesOutTangent`; // Interpolated frames rename string // string $name = `textFieldGrp -q -text replaceGeometryCacheFramesInterpFilename`; if( size($name) == 0 ) { $name = "backup"; } optionVar -stringValue replaceGeometryCacheFramesInterpRename $name; // simulation rate // optionVar -floatValue replaceGeometryCacheFramesSimulationRate `floatFieldGrp -query -v1 replaceGeometryCacheFramesSimulationRate`; // sampling rate // optionVar -intValue replaceGeometryCacheFramesSampleMultiplier `intFieldGrp -query -v1 replaceGeometryCacheFramesSampleMultiplier`; int $noBackups = `checkBoxGrp -q -v1 replaceGeometryCacheFramesDeleteBackups`; optionVar -intValue replaceGeometryCacheFramesNoBackups $noBackups; if( $doIt ) { performReplaceGeometryCacheFrames 0; } } // // Procedure Name: // replaceGeometryCacheFramesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc replaceGeometryCacheFramesOptions() { // Name of the command for this option box. // string $commandName = "replaceGeometryCacheFrames"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; tabLayout -tv false -scr true; string $parent = `columnLayout -adjustableColumn 1`; radioButtonGrp -l1 (uiRes("m_performReplaceGeometryCacheFrames.kCurrentTime")) -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesTimeRange1; radioButtonGrp -label "" -nrb 1 -scl replaceGeometryCacheFramesTimeRange1 -l1 (uiRes("m_performReplaceGeometryCacheFrames.kStartEnd")) -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesTimeRange2; separator -h 5 -style "none"; floatFieldGrp -label (uiRes("m_performReplaceGeometryCacheFrames.kSimulationRate")) -extraLabel (uiRes("m_performReplaceGeometryCacheFrames.kSimulationRateEnd")) -nf 1 -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesSimulationRate; intFieldGrp -label (uiRes("m_performReplaceGeometryCacheFrames.kSampleMultiplier")) -extraLabel (uiRes("m_performReplaceGeometryCacheFrames.kSampleMultiplierEnd")) -nf 1 -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesSampleMultiplier; checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 (uiRes("m_performReplaceGeometryCacheFrames.kDeleteBackups")) -v1 0 replaceGeometryCacheFramesDeleteBackups; separator -h 10; radioButtonGrp -label "" -label1 (uiRes("m_performReplaceGeometryCacheFrames.kNoInterpolation")) -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesInterpType1; radioButtonGrp -label "" -nrb 1 -scl replaceGeometryCacheFramesInterpType1 -label1 (uiRes("m_performReplaceGeometryCacheFrames.kInterpolateFrames")) -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesInterpType2; radioButtonGrp -label "" -nrb 1 -scl replaceGeometryCacheFramesInterpType1 -label1 (uiRes("m_performReplaceGeometryCacheFrames.kRenameInterpolateFrames")) -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesInterpType3; separator -h 5 -style "none"; textFieldGrp -label "" -cc "replaceGeometryCacheFramesEnabling" replaceGeometryCacheFramesInterpFilename; separator -h 5 -style "none"; string $linear = (uiRes("m_performReplaceGeometryCacheFrames.kLinear")); string $smooth = (uiRes("m_performReplaceGeometryCacheFrames.kSmooth")); string $step = (uiRes("m_performReplaceGeometryCacheFrames.kStep")); optionMenuGrp -cc "replaceGeometryCacheFramesEnabling" -label (uiRes("m_performReplaceGeometryCacheFrames.kInTangent")) replaceGeometryCacheFramesInTangent; menuItem -label $linear linearIn; menuItem -label $smooth smoothIn; menuItem -label $step stepIn; floatFieldGrp -nf 1 -cc "replaceGeometryCacheFramesEnabling" -label (uiRes("m_performReplaceGeometryCacheFrames.kInterpStart")) replaceGeometryCacheFramesInterpStart; floatFieldGrp -nf 1 -cc "replaceGeometryCacheFramesEnabling" -label (uiRes("m_performReplaceGeometryCacheFrames.kReplaceStart")) replaceGeometryCacheFramesReplaceStart; floatFieldGrp -nf 1 -cc "replaceGeometryCacheFramesEnabling" -label (uiRes("m_performReplaceGeometryCacheFrames.kReplaceEnd")) replaceGeometryCacheFramesReplaceEnd; floatFieldGrp -nf 1 -cc "replaceGeometryCacheFramesEnabling" -label (uiRes("m_performReplaceGeometryCacheFrames.kInterpEnd")) replaceGeometryCacheFramesInterpEnd; optionMenuGrp -cc "replaceGeometryCacheFramesEnabling" -label (uiRes("m_performReplaceGeometryCacheFrames.kOutTangent")) replaceGeometryCacheFramesOutTangent; menuItem -label $linear linearOut; menuItem -label $smooth smoothOut; menuItem -label $step stepOut; separator -h 10 -style "none"; string $warning = ( (uiRes("m_performReplaceGeometryCacheFrames.kMultiCacheWarning1")) + (uiRes("m_performReplaceGeometryCacheFrames.kMultiCacheWarning2")) + (uiRes("m_performReplaceGeometryCacheFrames.kMultiCacheWarning3")) ); text -label $warning; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performReplaceGeometryCacheFrames.kReplace")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle( (uiRes("m_performReplaceGeometryCacheFrames.kReplaceOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "ReplaceGeometryCacheFrames" ); // Set the current values of the option box. // eval( $setup + " " + $parent + " " + 0 ); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { setOptionVars(false); string $obj; float $startTime, $endTime; string $cmd = "cacheFile -refresh -replaceCachedFrame"; string $objects[] = getGeometriesToCache(); for( $obj in $objects ) { $cmd += (" -points " + $obj); } int $timeMode = `optionVar -query replaceGeometryCacheFramesTimeRange`; switch( $timeMode ) { case 1: $startTime = `currentTime -q`; $endTime = `currentTime -q`; break; case 2: default: $startTime = `optionVar -query replaceGeometryCacheFramesStartTime`; $endTime = `optionVar -query replaceGeometryCacheFramesEndTime`; break; } int $interpType = `optionVar -q replaceGeometryCacheFramesInterpType`; if( $interpType != 1 ) { float $interpStart = `optionVar -q replaceGeometryCacheFramesInterpStartTime`; float $interpEnd = `optionVar -q replaceGeometryCacheFramesInterpEndTime`; $cmd += (" -interpStartTime " + $interpStart ); $cmd += (" -interpEndTime " + $interpEnd ); int $inTangentVal = `optionVar -q repGeomCacheFramesInTan`; int $outTangentVal = `optionVar -q repGeomCacheFramesOutTan`; string $inTangent = "linear"; string $outTangent = "linear"; if ($inTangentVal == 2) { $inTangent = "smooth"; } else if ($inTangentVal == 3) { $inTangent = "step"; } if ($outTangentVal == 2) { $outTangent = "smooth"; } else if ($outTangentVal == 3) { $outTangent = "step"; } $cmd += (" -inTangent " + $inTangent ); $cmd += (" -outTangent " + $outTangent ); } if( $interpType == 3 ) { string $rename = `optionVar -q replaceGeometryCacheFramesInterpRename`; if( size($rename) == 0 ) { $rename = "backup"; } $cmd += (" -fileName \"" + $rename + "\""); } float $simRate = `optionVar -query replaceGeometryCacheFramesSimulationRate`; int $sampleMult = `optionVar -query replaceGeometryCacheFramesSampleMultiplier`; $cmd += (" -startTime " + $startTime ); $cmd += (" -endTime " + $endTime ); $cmd += (" -simulationRate " + $simRate ); $cmd += (" -sampleMultiplier " + $sampleMult ); int $noBackups = `optionVar -q replaceGeometryCacheFramesNoBackups`; if( $noBackups ) { $cmd += " -noBackup"; } string $cacheFiles[] = `ls -sl -type cacheFile`; if( size($cacheFiles) == 1 ) { $cmd += (" -cacheFileNode " + $cacheFiles[0] ); } return $cmd; } // // Procedure Name: // performReplaceGeometryCacheFrames // // Description: // Perform the command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performReplaceGeometryCacheFrames(int $action) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = `assembleCmd`; evalEcho($cmd); break; // Show the option box. // case 1: replaceGeometryCacheFramesOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }