// =========================================================================== // 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. // =========================================================================== // Description: // An option window used to publish a node as parent/child to a container. // // // 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) { if ($forceFactorySettings || !`optionVar -exists publishParentName`) { optionVar -stringValue publishParentName "parent"; } if ($forceFactorySettings || !`optionVar -exists publishChildName`) { optionVar -stringValue publishChildName "child"; } } // // Procedure Name: // publishNodeSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parentLayout - 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. // asParent - indicates if we're publishing as parent/child // // Return Value: // None. // global proc publishNodeSetup(string $parentLayout, int $forceFactorySettings, int $asParent) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parentLayout; string $name = ($asParent) ? `optionVar -q publishParentName` : `optionVar -q publishChildName`; textFieldGrp -e -text $name publishNameGrp; } // // Procedure Name: // publishNodeCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parentLayout - 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. // asParent - indicates whether we're publishing as parent/child // // Return Value: // None. // global proc publishNodeCallback(string $parentLayout, int $doIt, int $asParent) { setParent $parentLayout; string $optionVarName = ($asParent) ? "publishParentName" : "publishChildName"; optionVar -stringValue $optionVarName `textFieldGrp -q -text publishNameGrp`; if ($doIt) { performPublishNode 0 $asParent; addToRecentCommandQueue ("performPublishNode 0 " + $asParent) "Publish Node"; } } // // Procedure Name: // publishNodeOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // $asParent - indicates if we're publishing as parent/child // // Return Value: // None. // proc publishNodeOptions( int $asParent ) { // Name of the command for this option box. // string $commandName = "publishNode"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName("container"); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parentLayout = `columnLayout -adjustableColumn 1`; columnLayout; // used for custom name or prefix // textFieldGrp -label (uiRes("m_performPublishNode.kCustomString")) publishNameGrp; setParent ..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -command ($callback + " " + $parentLayout + " " + 1 + " " + $asParent) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback+" "+$parentLayout+" "+0+" "+$asParent+"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parentLayout + " " + 1 + " " +$asParent) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performPublishNode.kPublishNodeOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "PublishNode" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parentLayout + " " + 0 + " " + $asParent)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // $asParent - indicates if we're publishing as parent or child // proc string assembleCmd(int $asParent) { setOptionVars(false); string $publishName = ($asParent) ? `optionVar -query publishParentName` : `optionVar -query publishChildName`; string $cmd = ("publishAnchorNodes " + $asParent + " 2 \"" + $publishName + "\" `ls -sl` 1"); return $cmd; } // // Procedure Name: // performPublishNode // // Description: // Perform the publish parent/child container 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 optionBoxExample1 command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // $asParent : indicates if we're publishing node as a parent or child // global proc string performPublishNode(int $action, int $asParent) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd $asParent`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: publishNodeOptions $asParent; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd $asParent`; break; } return $cmd; }