// =========================================================================== // 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: 3 Oct 2007 // // Description: // This script provides an option box dialog for the polyHole command. // // Input Arguments: // boolean showOptionBox true - show the option box dialog // false - just execute the command // proc setOptionVars(int $forceFactorySettings) { // Default 1 means to assign hole if( $forceFactorySettings || !`optionVar -exists polyAssignSubdivHole`) optionVar -intValue polyAssignSubdivHole 1; } global proc polyHoleSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; $val = `optionVar -query polyAssignSubdivHole` + 1; radioButtonGrp -e -sl $val polyAssignSubdivHoleButton; } global proc polyHoleCallback(string $parent) { int $val = `radioButtonGrp -query -sl polyAssignSubdivHoleButton` - 1; optionVar -iv polyAssignSubdivHole $val; performPolyHoleFace false; } proc creationOptionBox() { // Name of the command for this option box // string $commandName = "polyHole"; // Build the option box "methods" // 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($commandName); // 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. tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; string $add = (uiRes("m_performPolyHoleFace.kAdd")); string $remove = (uiRes("m_performPolyHoleFace.kRemove")); radioButtonGrp -nrb 2 -label (uiRes("m_performPolyHoleFace.kHole")) -label1 $remove -label2 $add polyAssignSubdivHoleButton; // 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 -label (uiRes("m_performPolyHoleFace.kCreate")) -command ($callback + " " + $parent) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + "; hideOptionBox") $saveBtn; // 'Reset' button string $resetBtn = getOptionBoxResetBtn(); int $resetToDefaults = 1; button -edit -command ($setup + " " + $parent + " " + $resetToDefaults) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performPolyHoleFace.kAssignSubdivHoleOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "AssignSubdivHoleOptions" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " " + 0); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string creation() { int $assign = `optionVar -query polyAssignSubdivHole`; string $cmd = "polyHole" + " -assignHole " + $assign; return $cmd; } global proc string performPolyHoleFace(int $showOptionBox) { string $cmd; if( $showOptionBox ) creationOptionBox; else { setOptionVars(false); $cmd = creation(); evalEcho($cmd); } return $cmd; }