// =========================================================================== // 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 replaceNclothCacheFramesTimeRange`) { optionVar -intValue replaceNclothCacheFramesTimeRange 1; } // startTime // if ($forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesStartTime`) { optionVar -floatValue replaceNclothCacheFramesStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesEndTime`) { optionVar -floatValue replaceNclothCacheFramesEndTime 10.0; } // Interpolation type // if( $forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesInterpType`) { optionVar -intValue replaceNclothCacheFramesInterpType 1; } // interpolation startTime // if ($forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesInterpStartTime`) { optionVar -floatValue replaceNclothCacheFramesInterpStartTime 1.0; } // Interpolation endTime // if ($forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesInterpEndTime`) { optionVar -floatValue replaceNclothCacheFramesInterpEndTime 10.0; } // Interpolated frames rename string // if ($forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesInterpRename`) { optionVar -stringValue replaceNclothCacheFramesInterpRename "backup"; } // In Tangent // if ($forceFactorySettings || !`optionVar -exists repNclothCacheFramesInTan`) { // 1 == linear optionVar -intValue repNclothCacheFramesInTan 1; } // Out Tangent // if ($forceFactorySettings || !`optionVar -exists repNclothCacheFramesOutTan`) { // 1 == linear optionVar -intValue repNclothCacheFramesOutTan 1; } // delete old unused string prefs if they are lingering around // if (`optionVar -exists replaceNclothCacheFramesInTangent`) { optionVar -rm replaceNclothCacheFramesInTangent; } if (`optionVar -exists replaceNclothCacheFramesOutTangent`) { optionVar -rm replaceNclothCacheFramesOutTangent; } // simulation rate // if ($forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesSimulationRate`) { optionVar -floatValue replaceNclothCacheFramesSimulationRate 1; } // sampling rate // if( $forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesSampleMultiplier` ) { optionVar -intValue replaceNclothCacheFramesSampleMultiplier 1; } // Delete backup files // if( $forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesNoBackups` ) { optionVar -intValue replaceNclothCacheFramesNoBackups 0; } // Replace with simulation data // if( $forceFactorySettings || !`optionVar -exists replaceNclothCacheFramesWithSimulation` ) { optionVar -intValue replaceNclothCacheFramesWithSimulation 0; } } // // Procedure Name: // replaceNclothCacheFramesEnabling // // 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 replaceNclothCacheFramesEnabling() { int $startEnd = ( `radioButtonGrp -q -sl replaceNclothCacheFramesTimeRange2` == 1 ); floatFieldGrp -edit -enable $startEnd replaceNclothCacheFramesReplaceStart; floatFieldGrp -edit -enable $startEnd replaceNclothCacheFramesReplaceEnd; floatFieldGrp -edit -enable $startEnd replaceNclothCacheFramesSimulationRate; intFieldGrp -edit -enable $startEnd replaceNclothCacheFramesSampleMultiplier; int $interp = ( `radioButtonGrp -q -sl replaceNclothCacheFramesInterpType1` == 0 ); floatFieldGrp -edit -enable $interp replaceNclothCacheFramesInterpStart; floatFieldGrp -edit -enable $interp replaceNclothCacheFramesInterpEnd; optionMenuGrp -edit -enable $interp replaceNclothCacheFramesInTangent; optionMenuGrp -edit -enable $interp replaceNclothCacheFramesOutTangent; int $rename = ( `radioButtonGrp -q -sl replaceNclothCacheFramesInterpType3` == 1 ); textFieldGrp -edit -enable $rename replaceNclothCacheFramesInterpFilename; } // // Procedure Name: // replaceNclothCacheFramesSetup // // 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 replaceNclothCacheFramesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query replaceNclothCacheFramesTimeRange`; eval( "radioButtonGrp -e -select 1 replaceNclothCacheFramesTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query replaceNclothCacheFramesStartTime`; float $endTime = `optionVar -query replaceNclothCacheFramesEndTime`; floatFieldGrp -edit -value1 $startTime replaceNclothCacheFramesReplaceStart; floatFieldGrp -edit -value1 $endTime replaceNclothCacheFramesReplaceEnd; // Interpolation // int $interpType = `optionVar -q replaceNclothCacheFramesInterpType`; eval( "radioButtonGrp -e -sl 1 replaceNclothCacheFramesInterpType" + $interpType); float $interpStart = `optionVar -query replaceNclothCacheFramesInterpStartTime`; float $interpEnd = `optionVar -query replaceNclothCacheFramesInterpEndTime`; floatFieldGrp -edit -value1 $interpStart replaceNclothCacheFramesInterpStart; floatFieldGrp -edit -value1 $interpEnd replaceNclothCacheFramesInterpEnd; int $inTangent = `optionVar -query repNclothCacheFramesInTan`; int $outTangent = `optionVar -query repNclothCacheFramesOutTan`; optionMenuGrp -edit -sl $inTangent replaceNclothCacheFramesInTangent; optionMenuGrp -edit -sl $outTangent replaceNclothCacheFramesOutTangent; string $rename = `optionVar -query replaceNclothCacheFramesInterpRename`; textFieldGrp -edit -text $rename replaceNclothCacheFramesInterpFilename; // Sampling information // float $simulation = `optionVar -q replaceNclothCacheFramesSimulationRate` ; floatFieldGrp -e -v1 $simulation replaceNclothCacheFramesSimulationRate ; int $samplingRate = `optionVar -q replaceNclothCacheFramesSampleMultiplier` ; intFieldGrp -edit -v1 $samplingRate replaceNclothCacheFramesSampleMultiplier ; int $noBackups = `optionVar -query replaceNclothCacheFramesNoBackups`; checkBoxGrp -e -v1 $noBackups replaceNclothCacheFramesDeleteBackups; int $withSimulation = `optionVar -query replaceNclothCacheFramesWithSimulation`; checkBoxGrp -e -v1 $withSimulation replaceNclothCacheFramesWithSimulation; replaceNclothCacheFramesEnabling(); } // // Procedure Name: // replaceNclothCacheFramesCallback // // 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 replaceNclothCacheFramesCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 1; if( `radioButtonGrp -q -sl replaceNclothCacheFramesTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl replaceNclothCacheFramesTimeRange2` ) { $timeRangeMode = 2; } optionVar -intValue replaceNclothCacheFramesTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue replaceNclothCacheFramesStartTime `floatFieldGrp -query -value1 replaceNclothCacheFramesReplaceStart`; optionVar -floatValue replaceNclothCacheFramesEndTime `floatFieldGrp -query -value1 replaceNclothCacheFramesReplaceEnd`; // Interpolation type // int $interpType; if( `radioButtonGrp -q -sl replaceNclothCacheFramesInterpType1` ) { $interpType = 1; } else if( `radioButtonGrp -q -sl replaceNclothCacheFramesInterpType2` ) { $interpType = 2; } else if( `radioButtonGrp -q -sl replaceNclothCacheFramesInterpType3` ) { $interpType = 3; } optionVar -intValue replaceNclothCacheFramesInterpType $interpType; // Interpolation start/end // optionVar -floatValue replaceNclothCacheFramesInterpStartTime `floatFieldGrp -q -v1 replaceNclothCacheFramesInterpStart`; optionVar -floatValue replaceNclothCacheFramesInterpEndTime `floatFieldGrp -q -v1 replaceNclothCacheFramesInterpEnd`; // In/out tangents optionVar -intValue repNclothCacheFramesInTan `optionMenuGrp -q -sl replaceNclothCacheFramesInTangent`; optionVar -intValue repNclothCacheFramesOutTan `optionMenuGrp -q -sl replaceNclothCacheFramesOutTangent`; // Interpolated frames rename string // string $name = `textFieldGrp -q -text replaceNclothCacheFramesInterpFilename`; if( size($name) == 0 ) { $name = "backup"; } optionVar -stringValue replaceNclothCacheFramesInterpRename $name; // simulation rate // optionVar -floatValue replaceNclothCacheFramesSimulationRate `floatFieldGrp -query -v1 replaceNclothCacheFramesSimulationRate`; // sampling rate // optionVar -intValue replaceNclothCacheFramesSampleMultiplier `intFieldGrp -query -v1 replaceNclothCacheFramesSampleMultiplier`; int $noBackups = `checkBoxGrp -q -v1 replaceNclothCacheFramesDeleteBackups`; optionVar -intValue replaceNclothCacheFramesNoBackups $noBackups; int $withSim = `checkBoxGrp -q -v1 replaceNclothCacheFramesWithSimulation`; optionVar -intValue replaceNclothCacheFramesWithSimulation $withSim; if( $doIt ) { performReplaceNclothCacheFrames 0; } } // // Procedure Name: // replaceNclothCacheFramesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc replaceNclothCacheFramesOptions() { // Name of the command for this option box. // string $commandName = "replaceNclothCacheFrames"; // 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 -label (uiRes("m_performReplaceNclothCacheFrames.kReplaceTimeRange")) -nrb 1 -l1 (uiRes("m_performReplaceNclothCacheFrames.kCurrentTime")) -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesTimeRange1; radioButtonGrp -label "" -l1 (uiRes("m_performReplaceNclothCacheFrames.kStartEnd")) -scl replaceNclothCacheFramesTimeRange1 -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesTimeRange2; floatFieldGrp -nf 1 -cc "replaceNclothCacheFramesEnabling" -label (uiRes("m_performReplaceNclothCacheFrames.kReplaceStart")) replaceNclothCacheFramesReplaceStart; floatFieldGrp -nf 1 -cc "replaceNclothCacheFramesEnabling" -label (uiRes("m_performReplaceNclothCacheFrames.kReplaceEnd")) replaceNclothCacheFramesReplaceEnd; floatFieldGrp -label (uiRes("m_performReplaceNclothCacheFrames.kSimulationRate")) -extraLabel (uiRes("m_performReplaceNclothCacheFrames.kSimulationRateEnd")) -nf 1 -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesSimulationRate; intFieldGrp -label (uiRes("m_performReplaceNclothCacheFrames.kSampleMultiplier")) -extraLabel (uiRes("m_performReplaceNclothCacheFrames.kSampleMultiplierEnd")) -nf 1 -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesSampleMultiplier; separator -h 5 -style "none"; checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 (uiRes("m_performReplaceNclothCacheFrames.kWithSimulation")) -v1 0 replaceNclothCacheFramesWithSimulation; checkBoxGrp -numberOfCheckBoxes 1 -label (uiRes("m_performReplaceNclothCacheFrames.kCleanup")) -label1 (uiRes("m_performReplaceNclothCacheFrames.kDeleteBackups")) -v1 0 replaceNclothCacheFramesDeleteBackups; separator -h 10; radioButtonGrp -label "" -label1 (uiRes("m_performReplaceNclothCacheFrames.kNoInterpolation")) -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesInterpType1; radioButtonGrp -label "" -nrb 1 -scl replaceNclothCacheFramesInterpType1 -label1 (uiRes("m_performReplaceNclothCacheFrames.kInterpolateFrames")) -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesInterpType2; radioButtonGrp -label "" -nrb 1 -scl replaceNclothCacheFramesInterpType1 -label1 (uiRes("m_performReplaceNclothCacheFrames.kRenameInterpolateFrames")) -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesInterpType3; separator -h 5 -style "none"; textFieldGrp -label "" -cc "replaceNclothCacheFramesEnabling" replaceNclothCacheFramesInterpFilename; separator -h 5 -style "none"; string $linear = (uiRes("m_performReplaceNclothCacheFrames.kLinear")); string $smooth = (uiRes("m_performReplaceNclothCacheFrames.kSmooth")); string $step = (uiRes("m_performReplaceNclothCacheFrames.kStep")); optionMenuGrp -cc "replaceNclothCacheFramesEnabling" -label (uiRes("m_performReplaceNclothCacheFrames.kInTangent")) replaceNclothCacheFramesInTangent; menuItem -label $linear linearIn; menuItem -label $smooth smoothIn; menuItem -label $step stepIn; floatFieldGrp -nf 1 -cc "replaceNclothCacheFramesEnabling" -label (uiRes("m_performReplaceNclothCacheFrames.kInterpStart")) replaceNclothCacheFramesInterpStart; floatFieldGrp -nf 1 -cc "replaceNclothCacheFramesEnabling" -label (uiRes("m_performReplaceNclothCacheFrames.kInterpEnd")) replaceNclothCacheFramesInterpEnd; optionMenuGrp -cc "replaceNclothCacheFramesEnabling" -label (uiRes("m_performReplaceNclothCacheFrames.kOutTangent")) replaceNclothCacheFramesOutTangent; menuItem -label $linear linearOut; menuItem -label $smooth smoothOut; menuItem -label $step stepOut; separator -h 10 -style "none"; string $warning = ( (uiRes("m_performReplaceNclothCacheFrames.kMultiCacheWarning1")) + (uiRes("m_performReplaceNclothCacheFrames.kMultiCacheWarning2")) + (uiRes("m_performReplaceNclothCacheFrames.kMultiCacheWarning3")) ); text -label $warning; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performReplaceNclothCacheFrames.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_performReplaceNclothCacheFrames.kReplaceOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "ReplaceNclothCacheFrames" ); // 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); int $interpType = `optionVar -q replaceNclothCacheFramesInterpType`; float $interpStart = 0; float $interpEnd = 0; string $inTangent = "linear"; string $outTangent = "linear"; string $rename = ""; if( $interpType != 1 ) { $interpStart = `optionVar -q replaceNclothCacheFramesInterpStartTime`; $interpEnd = `optionVar -q replaceNclothCacheFramesInterpEndTime`; int $inTangentVal = `optionVar -q repNclothCacheFramesInTan`; int $outTangentVal = `optionVar -q repNclothCacheFramesOutTan`; if ($inTangentVal == 2) { $inTangent = "smooth"; } else if ($inTangentVal == 3) { $inTangent = "step"; } if ($outTangentVal == 2) { $outTangent = "smooth"; } else if ($outTangentVal == 3) { $outTangent = "step"; } if( $interpType == 3 ) { $rename = `optionVar -q replaceNclothCacheFramesInterpRename`; if( size($rename) == 0 ) { $rename = "backup"; } } } return( "doReplaceNclothCacheFrames " + `optionVar -query replaceNclothCacheFramesTimeRange` + " " + `optionVar -query replaceNclothCacheFramesStartTime` + " " + `optionVar -query replaceNclothCacheFramesEndTime` + " " + `optionVar -q replaceNclothCacheFramesWithSimulation` + " " + $interpType + " " + $interpStart + " " + $interpEnd + " \"" + $inTangent + "\" \"" + $outTangent + "\" \"" + $rename + "\" " + `optionVar -query replaceNclothCacheFramesSimulationRate` + " " + `optionVar -query replaceNclothCacheFramesSampleMultiplier` + " " + `optionVar -q replaceNclothCacheFramesNoBackups` ); } // // Procedure Name: // performReplaceNclothCacheFrames // // 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 performReplaceNclothCacheFrames(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: replaceNclothCacheFramesOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }