// =========================================================================== // 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 deleteGeometryCacheFramesTimeRange`) { optionVar -intValue deleteGeometryCacheFramesTimeRange 1; } // startTime // if ($forceFactorySettings || !`optionVar -exists deleteGeometryCacheFramesStartTime`) { optionVar -floatValue deletenClothCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists deleteGeometryCacheFramesEndTime`) { optionVar -floatValue deleteGeometryCacheFramesEndTime 10.0; } // Frame renaming if ($forceFactorySettings || !`optionVar -exists deleteGeometryCacheFramesRenameType`) { optionVar -intValue deleteGeometryCacheFramesRenameType 1; } // Frames rename string // if ($forceFactorySettings || !`optionVar -exists deleteGeometryCacheFramesRename`) { optionVar -stringValue deleteGeometryCacheFramesRename "backup"; } // Delete backup files // if ($forceFactorySettings || !`optionVar -exists deleteGeometryCacheFramesNoBackups`) { optionVar -intValue deleteGeometryCacheFramesNoBackups 0; } } // // Procedure Name: // deleteGeometryCacheFramesEnabling // // 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 deleteGeometryCacheFramesEnabling() { int $startEnd = ( `radioButtonGrp -q -sl deleteGeometryCacheFramesTimeRange2` == 1 ); floatFieldGrp -edit -enable $startEnd deleteGeometryCacheFramesDeleteStart; floatFieldGrp -edit -enable $startEnd deleteGeometryCacheFramesDeleteEnd; int $rename = ( `radioButtonGrp -q -sl deleteGeometryCacheFramesRenameType2` == 1 ); textFieldGrp -edit -enable $rename deleteGeometryCacheFramesFilename; } // // Procedure Name: // deleteGeometryCacheFramesSetup // // 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 deleteGeometryCacheFramesSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query deleteGeometryCacheFramesTimeRange`; eval( "radioButtonGrp -e -select 1 deleteGeometryCacheFramesTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query deleteGeometryCacheFramesStartTime`; float $endTime = `optionVar -query deleteGeometryCacheFramesEndTime`; floatFieldGrp -edit -value1 $startTime deleteGeometryCacheFramesDeleteStart; floatFieldGrp -edit -value1 $endTime deleteGeometryCacheFramesDeleteEnd; int $renameType = `optionVar -q deleteGeometryCacheFramesRenameType`; eval( "radioButtonGrp -e -sl 1 deleteGeometryCacheFramesRenameType" + $renameType); string $rename = `optionVar -query deleteGeometryCacheFramesRename`; textFieldGrp -edit -text $rename deleteGeometryCacheFramesFilename; int $noBackups = `optionVar -query deleteGeometryCacheFramesNoBackups`; checkBoxGrp -e -v1 $noBackups deleteGeometryCacheFramesDeleteBackups; deleteGeometryCacheFramesEnabling(); } // // Procedure Name: // deleteGeometryCacheFramesCallback // // 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 deleteGeometryCacheFramesCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 1; if( `radioButtonGrp -q -sl deleteGeometryCacheFramesTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl deleteGeometryCacheFramesTimeRange2` ) { $timeRangeMode = 2; } optionVar -intValue deleteGeometryCacheFramesTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue deleteGeometryCacheFramesStartTime `floatFieldGrp -query -value1 deleteGeometryCacheFramesDeleteStart`; optionVar -floatValue deleteGeometryCacheFramesEndTime `floatFieldGrp -query -value1 deleteGeometryCacheFramesDeleteEnd`; // Frame rename string // int $renameType; if( `radioButtonGrp -q -sl deleteGeometryCacheFramesRenameType1` ) { $renameType = 1; } else if( `radioButtonGrp -q -sl deleteGeometryCacheFramesRenameType2` ) { $renameType = 2; } optionVar -intValue deleteGeometryCacheFramesRenameType $renameType; string $name = `textFieldGrp -q -text deleteGeometryCacheFramesFilename`; if( size($name) == 0 ) { $name = "backup"; } optionVar -stringValue deleteGeometryCacheFramesRename $name; int $noBackups = `checkBoxGrp -q -v1 deleteGeometryCacheFramesDeleteBackups`; optionVar -intValue deleteGeometryCacheFramesNoBackups $noBackups; if( $doIt ) { performDeleteGeometryCacheFrames 0; } } // // Procedure Name: // deleteGeometryCacheFramesOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc deleteGeometryCacheFramesOptions() { // Name of the command for this option box. // string $commandName = "deleteGeometryCacheFrames"; // 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_performDeleteGeometryCacheFrames.kDeleteTime")) -l1 (uiRes("m_performDeleteGeometryCacheFrames.kCurrentTime")) -cc "deleteGeometryCacheFramesEnabling" deleteGeometryCacheFramesTimeRange1; radioButtonGrp -label "" -nrb 1 -scl deleteGeometryCacheFramesTimeRange1 -l1 (uiRes("m_performDeleteGeometryCacheFrames.kStartEnd")) -cc "deleteGeometryCacheFramesEnabling" deleteGeometryCacheFramesTimeRange2; floatFieldGrp -nf 1 -cc "deleteGeometryCacheFramesEnabling" -label (uiRes("m_performDeleteGeometryCacheFrames.kDeleteStart")) deleteGeometryCacheFramesDeleteStart; floatFieldGrp -nf 1 -cc "deleteGeometryCacheFramesEnabling" -label (uiRes("m_performDeleteGeometryCacheFrames.kDeleteEnd")) deleteGeometryCacheFramesDeleteEnd; separator -h 5 -style "none"; radioButtonGrp -label (uiRes("m_performDeleteGeometryCacheFrames.kRenaming")) -label1 (uiRes("m_performDeleteGeometryCacheFrames.kDefaultNaming")) -cc "deleteGeometryCacheFramesEnabling" deleteGeometryCacheFramesRenameType1; radioButtonGrp -label "" -nrb 1 -scl deleteGeometryCacheFramesRenameType1 -label1 (uiRes("m_performDeleteGeometryCacheFrames.kCustomRename")) -annotation (uiRes("m_performDeleteGeometryCacheFrames.kCustomRenameAnnot")) -cc "deleteGeometryCacheFramesEnabling" deleteGeometryCacheFramesRenameType2; separator -h 5 -style "none"; textFieldGrp -label (uiRes("m_performDeleteGeometryCacheFrames.kCustomPrefix")) -cc "deleteGeometryCacheFramesEnabling" deleteGeometryCacheFramesFilename; separator -h 5 -style "none"; checkBoxGrp -numberOfCheckBoxes 1 -label (uiRes("m_performDeleteGeometryCacheFrames.kCleanup")) -label1 (uiRes("m_performDeleteGeometryCacheFrames.kDeleteBackups")) -v1 0 deleteGeometryCacheFramesDeleteBackups; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performDeleteGeometryCacheFrames.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_performDeleteGeometryCacheFrames.kDeleteOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "DeleteGeometryCacheFrames" ); // 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"; string $objects[] = getGeometriesToCache(); for( $obj in $objects ) { $cmd += (" -points " + $obj); } int $timeMode = `optionVar -query deleteGeometryCacheFramesTimeRange`; switch( $timeMode ) { case 1: $startTime = `currentTime -q`; $endTime = `currentTime -q`; break; case 2: default: $startTime = `optionVar -query deleteGeometryCacheFramesStartTime`; $endTime = `optionVar -query deleteGeometryCacheFramesEndTime`; break; } int $renameType = `optionVar -q deleteGeometryCacheFramesRenameType`; if( $renameType == 2 ) { string $rename = `optionVar -q deleteGeometryCacheFramesRename`; if( size($rename) == 0 ) { $rename = "backup"; } $cmd += (" -fileName \"" + $rename +"\""); } $cmd += (" -startTime " + $startTime ); $cmd += (" -endTime " + $endTime ); int $noBackups = `optionVar -q deleteGeometryCacheFramesNoBackups`; if( $noBackups ) { $cmd += " -noBackup"; } return $cmd; } // // Procedure Name: // performDeleteGeometryCacheFrames // // 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 performDeleteGeometryCacheFrames(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: deleteGeometryCacheFramesOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }