// =========================================================================== // 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. // Please note that this script is used to delete both nCloth and fluid caches. // // // 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 deleteFluidCacheFramesTimeRange`) { optionVar -intValue deleteFluidCacheFramesTimeRange 1; } // startTime // if ($forceFactorySettings || !`optionVar -exists deleteFluidCacheFramesStartTime`) { optionVar -floatValue deleteFluidCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists deleteFluidCacheFramesEndTime`) { optionVar -floatValue deleteFluidCacheFramesEndTime 10.0; } // Frame renaming if ($forceFactorySettings || !`optionVar -exists deleteFluidCacheFramesRenameType`) { optionVar -intValue deleteFluidCacheFramesRenameType 1; } // Frames rename string // if ($forceFactorySettings || !`optionVar -exists deleteFluidCacheFramesRename`) { optionVar -stringValue deleteFluidCacheFramesRename "backup"; } // Delete backup files // if ($forceFactorySettings || !`optionVar -exists deleteFluidCacheFramesNoBackups`) { optionVar -intValue deleteFluidCacheFramesNoBackups 0; } } // // Procedure Name: // deleteFluidCacheFramesEnabling // // 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 deleteFluidCacheFramesEnabling() { int $startEnd = ( `radioButtonGrp -q -sl deleteFluidCacheFramesTimeRange2` == 1 ); floatFieldGrp -edit -enable $startEnd deleteFluidCacheFramesDeleteStart; floatFieldGrp -edit -enable $startEnd deleteFluidCacheFramesDeleteEnd; int $rename = ( `radioButtonGrp -q -sl deleteFluidCacheFramesRenameType2` == 1 ); textFieldGrp -edit -enable $rename deleteFluidCacheFramesFilename; } // // Procedure Name: // deleteFluidCacheFramesSetup // // 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 deleteFluidCacheFramesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query deleteFluidCacheFramesTimeRange`; eval( "radioButtonGrp -e -select 1 deleteFluidCacheFramesTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query deleteFluidCacheFramesStartTime`; float $endTime = `optionVar -query deleteFluidCacheFramesEndTime`; floatFieldGrp -edit -value1 $startTime deleteFluidCacheFramesDeleteStart; floatFieldGrp -edit -value1 $endTime deleteFluidCacheFramesDeleteEnd; int $renameType = `optionVar -q deleteFluidCacheFramesRenameType`; eval( "radioButtonGrp -e -sl 1 deleteFluidCacheFramesRenameType" + $renameType); string $rename = `optionVar -query deleteFluidCacheFramesRename`; textFieldGrp -edit -text $rename deleteFluidCacheFramesFilename; int $noBackups = `optionVar -query deleteFluidCacheFramesNoBackups`; checkBoxGrp -e -v1 $noBackups deleteFluidCacheFramesDeleteBackups; deleteFluidCacheFramesEnabling(); } // // Procedure Name: // deleteFluidCacheFramesCallback // // 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 deleteFluidCacheFramesCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 1; if( `radioButtonGrp -q -sl deleteFluidCacheFramesTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl deleteFluidCacheFramesTimeRange2` ) { $timeRangeMode = 2; } optionVar -intValue deleteFluidCacheFramesTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue deleteFluidCacheFramesStartTime `floatFieldGrp -query -value1 deleteFluidCacheFramesDeleteStart`; optionVar -floatValue deleteFluidCacheFramesEndTime `floatFieldGrp -query -value1 deleteFluidCacheFramesDeleteEnd`; // Frame rename string // int $renameType; if( `radioButtonGrp -q -sl deleteFluidCacheFramesRenameType1` ) { $renameType = 1; } else if( `radioButtonGrp -q -sl deleteFluidCacheFramesRenameType2` ) { $renameType = 2; } optionVar -intValue deleteFluidCacheFramesRenameType $renameType; string $name = `textFieldGrp -q -text deleteFluidCacheFramesFilename`; if( size($name) == 0 ) { $name = "backup"; } optionVar -stringValue deleteFluidCacheFramesRename $name; int $noBackups = `checkBoxGrp -q -v1 deleteFluidCacheFramesDeleteBackups`; optionVar -intValue deleteFluidCacheFramesNoBackups $noBackups; if( $doIt ) { performDeleteFluidCacheFrames 0; } } // // Procedure Name: // deleteFluidCacheFramesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc deleteFluidCacheFramesOptions() { // Name of the command for this option box. // string $commandName = "deleteFluidCacheFrames"; // 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_performDeleteFluidCacheFrames.kFluidCurrentTime")) -cc "deleteFluidCacheFramesEnabling" deleteFluidCacheFramesTimeRange1; radioButtonGrp -label "" -nrb 1 -scl deleteFluidCacheFramesTimeRange1 -l1 (uiRes("m_performDeleteFluidCacheFrames.kFluidStartEnd")) -cc "deleteFluidCacheFramesEnabling" deleteFluidCacheFramesTimeRange2; floatFieldGrp -nf 1 -cc "deleteFluidCacheFramesEnabling" -label (uiRes("m_performDeleteFluidCacheFrames.kFluidDeleteStart")) deleteFluidCacheFramesDeleteStart; floatFieldGrp -nf 1 -cc "deleteFluidCacheFramesEnabling" -label (uiRes("m_performDeleteFluidCacheFrames.kFluidDeleteEnd")) deleteFluidCacheFramesDeleteEnd; separator -h 5 -style "none"; radioButtonGrp -label "" -label1 (uiRes("m_performDeleteFluidCacheFrames.kFluidDefaultNaming")) -cc "deleteFluidCacheFramesEnabling" deleteFluidCacheFramesRenameType1; radioButtonGrp -label "" -nrb 1 -scl deleteFluidCacheFramesRenameType1 -label1 (uiRes("m_performDeleteFluidCacheFrames.kFluidCustomRename")) -cc "deleteFluidCacheFramesEnabling" deleteFluidCacheFramesRenameType2; separator -h 5 -style "none"; textFieldGrp -label "" -cc "deleteFluidCacheFramesEnabling" deleteFluidCacheFramesFilename; checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 (uiRes("m_performDeleteFluidCacheFrames.kFluidDeleteBackups")) -v1 0 deleteFluidCacheFramesDeleteBackups; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performDeleteFluidCacheFrames.kFluidDelete")) -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_performDeleteFluidCacheFrames.kDeleteOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "DeleteFluidCacheFrames" ); // 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 -deleteCachedFrame"; // This command is now used as delete cache frames for both Ncloth and fluid. string $objects[] = getFluidObjectsToCache(0); string $nClothObjects[] = getNclothObjectsToCache(0); $objects = stringArrayCatenate($objects, $nClothObjects); for( $obj in $objects ) { $cmd += (" -cacheableNode " + $obj); } int $timeMode = `optionVar -query deleteFluidCacheFramesTimeRange`; switch( $timeMode ) { case 1: $startTime = `currentTime -q`; $endTime = `currentTime -q`; break; case 2: default: $startTime = `optionVar -query deleteFluidCacheFramesStartTime`; $endTime = `optionVar -query deleteFluidCacheFramesEndTime`; break; } int $renameType = `optionVar -q deleteFluidCacheFramesRenameType`; if( $renameType == 2 ) { string $rename = `optionVar -q deleteFluidCacheFramesRename`; if( size($rename) == 0 ) { $rename = "backup"; } $cmd += (" -fileName \"" + $rename + "\""); } $cmd += (" -startTime " + $startTime ); $cmd += (" -endTime " + $endTime ); int $noBackups = `optionVar -q deleteFluidCacheFramesNoBackups`; if( $noBackups ) { $cmd += " -noBackup"; } return $cmd; } // // Procedure Name: // performDeleteFluidCacheFrames // // 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 performDeleteFluidCacheFrames(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: deleteFluidCacheFramesOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }