// =========================================================================== // 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 renderLayer. // A renderLayer 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) { // Render layer base index // if ($forceFactorySettings || !`optionVar -exists renderLayerBase`) { optionVar -intValue renderLayerBase 1; } // Set to Current flag // if ($forceFactorySettings || !`optionVar -exists renderLayerCurrent`) { optionVar -intValue renderLayerCurrent false; } // Contents flag // if ($forceFactorySettings || !`optionVar -exists renderLayerContents`) { optionVar -intValue renderLayerContents 1; } } // // Procedure Name: // createRenderLayerSetup // // 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 createRenderLayerSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); // Layer name textFieldGrp -e -text "layer1" renderLayerNameWidget; // Base layer index int $base = `optionVar -q renderLayerBase`; intFieldGrp -e -v1 $base renderLayerBaseWidget; // Contents flag int $contents = `optionVar -q renderLayerContents`; radioButtonGrp -e -sl $contents contentsRadio; // Set to Current flag int $current = `optionVar -q renderLayerCurrent`; checkBoxGrp -e -v1 $current currentCheck; setParent $parent; } // // Procedure Name: // createRenderLayerCallback // // 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 createRenderLayerCallback(string $parent, int $doIt) { setParent $parent; // Contents flag // optionVar -iv renderLayerContents `radioButtonGrp -q -sl contentsRadio`; // 'Make current' flag // optionVar -iv renderLayerCurrent `checkBoxGrp -q -v1 currentCheck`; // Base layer index // optionVar -iv renderLayerBase `intFieldGrp -q -v1 renderLayerBaseWidget`; if ($doIt) { performCreateRenderLayer 0; addToRecentCommandQueue "performCreateRenderLayer 0" "CreateRenderLayer"; } } // // Procedure Name: // createRenderLayerHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string createRenderLayerHelp() { return " Command: Create Render Layer - create a renderLayer.\n" + "Selection: Selected DAG objects are added to the renderLayer."; } // // 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 renderLayer name string $renderLayerName = "layer1"; if (`textFieldGrp -exists renderLayerNameWidget`) { $renderLayerName = `textFieldGrp -q -text renderLayerNameWidget`; } // get the renderLayer base number int $renderLayerBase = `optionVar -q renderLayerBase`; // create the renderLayer command string if (0 == size($renderLayerName)) { $renderLayerName = "layer1"; } $renderLayerName = "\"" + $renderLayerName + "\""; $cmd = "createRenderLayer -name " + $renderLayerName + " -number " + $renderLayerBase; int $contents = `optionVar -q renderLayerContents`; int $current = `optionVar -q renderLayerCurrent`; if( $current ) $cmd += " -makeCurrent"; if( $contents == 1 ) { $cmd += " -empty"; } else if( $contents == 2 ) { $cmd += " -noRecurse `ls -selection`"; } else if ($contents == 3 ) { $cmd += " `ls -selection`"; } else if ($contents == 4 ) { $cmd += " -global"; } return $cmd; } // // Procedure Name: // performCreateRenderLayer // // Description: // Perform the create render layer command using the corresponding // option values. This procedure will also construct the command string // that will invoke the createRenderLayer command. // Note: no option box is associated with this command. // // Input Arguments: // 0 - Execute the command. // 1 - Return the command. // global proc string performCreateRenderLayer(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; }