// =========================================================================== // 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: October 30, 1998 // // Description: // // An option window used to create a named displayLayer. // A displayLayer is a grouping of DAG objects used to control drawing. // // // 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) { // Display layer base index // if ($forceFactorySettings || !`optionVar -exists displayLayerBase`) { optionVar -intValue displayLayerBase 1; } // Set to Current flag // if ($forceFactorySettings || !`optionVar -exists displayLayerCurrent`) { optionVar -intValue displayLayerCurrent false; } // Set to Show Namespace // if ($forceFactorySettings || !`optionVar -exists displayLayerShowNamespace`) { optionVar -intValue displayLayerShowNamespace true; } // Contents flag // if ($forceFactorySettings || !`optionVar -exists displayLayerContents`) { optionVar -intValue displayLayerContents 1; } } // // Procedure Name: // createDisplayLayerSetup // // 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 createDisplayLayerSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); // Layer name textFieldGrp -e -text "layer1" displayLayerNameWidget; // Base layer index int $base = `optionVar -q displayLayerBase`; intFieldGrp -e -v1 $base displayLayerBaseWidget; // Contents flag int $contents = `optionVar -q displayLayerContents`; radioButtonGrp -e -sl $contents contentsRadio; // Set to Current flag int $current = `optionVar -q displayLayerCurrent`; checkBoxGrp -e -v1 $current currentCheck; setParent $parent; } // // Procedure Name: // createDisplayLayerCallback // // 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 createDisplayLayerCallback(string $parent, int $doIt) { setParent $parent; // Contents flag // optionVar -iv displayLayerContents `radioButtonGrp -q -sl contentsRadio`; // 'Make current' flag // optionVar -iv displayLayerCurrent `checkBoxGrp -q -v1 currentCheck`; // Base layer index // optionVar -iv displayLayerBase `intFieldGrp -q -v1 displayLayerBaseWidget`; if ($doIt) { performCreateDisplayLayer 0; addToRecentCommandQueue "performCreateDisplayLayer 0" "CreateDisplayLayer"; } } // // Procedure Name: // createDisplayLayerHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string createDisplayLayerHelp() { return " Command: Create Display Layer - create a displayLayer.\n" + "Selection: Selected DAG objects are added to the displayLayer."; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd; setOptionVars(false); // get the displayLayer name string $displayLayerName = "layer1"; if (`textFieldGrp -exists displayLayerNameWidget`) { $displayLayerName = `textFieldGrp -q -text displayLayerNameWidget`; } // get the displayLayer base number int $displayLayerBase = `optionVar -q displayLayerBase`; // create the displayLayer command string if (0 == size($displayLayerName)) { $displayLayerName = "layer1"; } $displayLayerName = "\"" + $displayLayerName + "\""; $cmd = "createDisplayLayer -name " + $displayLayerName + " -number " + $displayLayerBase; int $contents = `optionVar -q displayLayerContents`; int $current = `optionVar -q displayLayerCurrent`; if( $contents == 1 ) { $cmd += " -empty"; } else if( $contents == 2 ) { $cmd += " -nr"; } if( $current ) $cmd += " -mc"; return $cmd; } // // Procedure Name: // performCreateDisplayLayer // // Description: // Perform the create display layer command using the corresponding // option values. This procedure will also construct the command string // that will invoke the createDisplayLayer. // Note: no option box is associated with this command. // // Input Arguments: // 0 - Execute the command. // 1 - Return the command. // global proc string performCreateDisplayLayer(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. evalEcho($cmd); break; // Return the command string. // case 1: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }