// =========================================================================== // 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 -delete" 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 deleteNclothCacheFramesTimeRange`) { optionVar -intValue deleteNclothCacheFramesTimeRange 1; } // startTime // if ($forceFactorySettings || !`optionVar -exists deleteNclothCacheFramesStartTime`) { optionVar -floatValue deletenClothCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists deleteNclothCacheFramesEndTime`) { optionVar -floatValue deleteNclothCacheFramesEndTime 10.0; } // Frame renaming if ($forceFactorySettings || !`optionVar -exists deleteNclothCacheFramesRenameType`) { optionVar -intValue deleteNclothCacheFramesRenameType 1; } // Frames rename string // if ($forceFactorySettings || !`optionVar -exists deleteNclothCacheFramesRename`) { optionVar -stringValue deleteNclothCacheFramesRename "backup"; } // Delete backup files // if ($forceFactorySettings || !`optionVar -exists deleteNclothCacheFramesNoBackups`) { optionVar -intValue deleteNclothCacheFramesNoBackups 0; } } // // Procedure Name: // deleteNclothCacheFramesEnabling // // 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 deleteNclothCacheFramesEnabling() { int $startEnd = ( `radioButtonGrp -q -sl deleteNclothCacheFramesTimeRange2` == 1 ); floatFieldGrp -edit -enable $startEnd deleteNclothCacheFramesDeleteStart; floatFieldGrp -edit -enable $startEnd deleteNclothCacheFramesDeleteEnd; int $rename = ( `radioButtonGrp -q -sl deleteNclothCacheFramesRenameType2` == 1 ); textFieldGrp -edit -enable $rename deleteNclothCacheFramesFilename; } // // Procedure Name: // deleteNclothCacheFramesSetup // // 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 deleteNclothCacheFramesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query deleteNclothCacheFramesTimeRange`; eval( "radioButtonGrp -e -select 1 deleteNclothCacheFramesTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query deleteNclothCacheFramesStartTime`; float $endTime = `optionVar -query deleteNclothCacheFramesEndTime`; floatFieldGrp -edit -value1 $startTime deleteNclothCacheFramesDeleteStart; floatFieldGrp -edit -value1 $endTime deleteNclothCacheFramesDeleteEnd; int $renameType = `optionVar -q deleteNclothCacheFramesRenameType`; eval( "radioButtonGrp -e -sl 1 deleteNclothCacheFramesRenameType" + $renameType); string $rename = `optionVar -query deleteNclothCacheFramesRename`; textFieldGrp -edit -text $rename deleteNclothCacheFramesFilename; int $noBackups = `optionVar -query deleteNclothCacheFramesNoBackups`; checkBoxGrp -e -v1 $noBackups deleteNclothCacheFramesDeleteBackups; deleteNclothCacheFramesEnabling(); } // // Procedure Name: // deleteNclothCacheFramesCallback // // 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 deleteNclothCacheFramesCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 1; if( `radioButtonGrp -q -sl deleteNclothCacheFramesTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl deleteNclothCacheFramesTimeRange2` ) { $timeRangeMode = 2; } optionVar -intValue deleteNclothCacheFramesTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue deleteNclothCacheFramesStartTime `floatFieldGrp -query -value1 deleteNclothCacheFramesDeleteStart`; optionVar -floatValue deleteNclothCacheFramesEndTime `floatFieldGrp -query -value1 deleteNclothCacheFramesDeleteEnd`; // Frame rename string // int $renameType; if( `radioButtonGrp -q -sl deleteNclothCacheFramesRenameType1` ) { $renameType = 1; } else if( `radioButtonGrp -q -sl deleteNclothCacheFramesRenameType2` ) { $renameType = 2; } optionVar -intValue deleteNclothCacheFramesRenameType $renameType; string $name = `textFieldGrp -q -text deleteNclothCacheFramesFilename`; if( size($name) == 0 ) { $name = "backup"; } optionVar -stringValue deleteNclothCacheFramesRename $name; int $noBackups = `checkBoxGrp -q -v1 deleteNclothCacheFramesDeleteBackups`; optionVar -intValue deleteNclothCacheFramesNoBackups $noBackups; if( $doIt ) { performDeleteNclothCacheFrames 0; } } // // Procedure Name: // deleteNclothCacheFramesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc deleteNclothCacheFramesOptions() { // Name of the command for this option box. // string $commandName = "deleteNclothCacheFrames"; // 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_performDeleteNclothCacheFrames.kDeleteTime")) -l1 (uiRes("m_performDeleteNclothCacheFrames.kCurrentTime")) -cc "deleteNclothCacheFramesEnabling" deleteNclothCacheFramesTimeRange1; radioButtonGrp -label "" -nrb 1 -scl deleteNclothCacheFramesTimeRange1 -l1 (uiRes("m_performDeleteNclothCacheFrames.kStartEnd")) -cc "deleteNclothCacheFramesEnabling" deleteNclothCacheFramesTimeRange2; floatFieldGrp -nf 1 -cc "deleteNclothCacheFramesEnabling" -label (uiRes("m_performDeleteNclothCacheFrames.kDeleteStart")) deleteNclothCacheFramesDeleteStart; floatFieldGrp -nf 1 -cc "deleteNclothCacheFramesEnabling" -label (uiRes("m_performDeleteNclothCacheFrames.kDeleteEnd")) deleteNclothCacheFramesDeleteEnd; separator -h 5 -style "none"; radioButtonGrp -label (uiRes("m_performDeleteNclothCacheFrames.kRenaming")) -label1 (uiRes("m_performDeleteNclothCacheFrames.kDefaultNaming")) -cc "deleteNclothCacheFramesEnabling" deleteNclothCacheFramesRenameType1; radioButtonGrp -label "" -nrb 1 -scl deleteNclothCacheFramesRenameType1 -label1 (uiRes("m_performDeleteNclothCacheFrames.kCustomRename")) -annotation (uiRes("m_performDeleteNclothCacheFrames.kCustomRenameAnnot")) -cc "deleteNclothCacheFramesEnabling" deleteNclothCacheFramesRenameType2; separator -h 5 -style "none"; textFieldGrp -label (uiRes("m_performDeleteNclothCacheFrames.kCustomPrefix")) -cc "deleteNclothCacheFramesEnabling" deleteNclothCacheFramesFilename; checkBoxGrp -numberOfCheckBoxes 1 -label (uiRes("m_performDeleteNclothCacheFrames.kCleanup")) -label1 (uiRes("m_performDeleteNclothCacheFrames.kDeleteBackups")) -v1 0 deleteNclothCacheFramesDeleteBackups; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performDeleteNclothCacheFrames.kDelete")) -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_performDeleteNclothCacheFrames.kDeleteOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "DeleteNclothCacheFrames" ); // 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 $rename = ""; if( `optionVar -q deleteNclothCacheFramesRenameType` == 2 ) { $rename = `optionVar -q deleteNclothCacheFramesRename`; if( size($rename) == 0 ) { $rename = "backup"; } } return( "doDeleteNclothCacheFrames " + `optionVar -query deleteNclothCacheFramesTimeRange` + " " + `optionVar -query deleteNclothCacheFramesStartTime` + " " + `optionVar -query deleteNclothCacheFramesEndTime` + " \"" + $rename + "\" " + `optionVar -q deleteNclothCacheFramesNoBackups` ); } // // Procedure Name: // performDeleteNclothCacheFrames // // 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 performDeleteNclothCacheFrames(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: deleteNclothCacheFramesOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }