// =========================================================================== // 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: November 25, 1996 // // Description: // Group option box script. // // Input Arguments: // bool if true show option box // if false perform command with current values // Return Value: // string new group node // proc setOptionVars (int $forceFactorySettings) { // World flag // if ($forceFactorySettings || !`optionVar -exists groupWorld`) { optionVar -intValue groupWorld false; } // Pivot flag // if ($forceFactorySettings || !`optionVar -exists groupZeroPivot`) { optionVar -intValue groupZeroPivot true; } // Absolute flag // if ($forceFactorySettings || !`optionVar -exists groupPreserve`) { optionVar -intValue groupPreserve true; } } global proc groupSetup (string $parent, int $forceFactorySettings) { int $boolToOption[] = { 1, 2 }; // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // World flag // int $world = `optionVar -q groupWorld`; radioButtonGrp -e -select $boolToOption[$world] groupUnder; // Pivot flag // int $pivot = `optionVar -q groupZeroPivot`; radioButtonGrp -e -select $boolToOption[$pivot] groupPivot; // Absolute flag // int $preserve = `optionVar -q groupPreserve`; checkBoxGrp -e -v1 $preserve groupCheck; } global proc string groupCallback (string $parent, int $doIt) { int $optionToBool[] = { 0, false, true }; string $ret = ""; setParent $parent; // Set the optionVar's from the control values, and then perform command // // World flag // int $i = `radioButtonGrp -q -select groupUnder`; optionVar -intValue groupWorld $optionToBool[$i]; // Pivot flag // int $j = `radioButtonGrp -q -select groupPivot`; optionVar -intValue groupZeroPivot $optionToBool[$j]; // Preserve flag // optionVar -intValue groupPreserve `checkBoxGrp -q -v1 groupCheck`; if ($doIt) { $ret = `performGroup false`; addToRecentCommandQueue "performGroup false" "Group"; } return $ret; } // // Procedure Name: // groupOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc groupOptions() { // Name of the command for this option box. // string $commandName = "group"; // 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($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. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performGroup.kGroupUnder")) -label1 (uiRes("m_performGroup.kParent")) -label2 (uiRes("m_performGroup.kWorld")) groupUnder; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performGroup.kGroupPivot")) -label1 (uiRes("m_performGroup.kCenter")) -label2 (uiRes("m_performGroup.kOrigin")) groupPivot; checkBoxGrp -numberOfCheckBoxes 1 -label1 (uiRes("m_performGroup.kPreservePosition")) groupCheck; // 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 -label (uiRes("m_performGroup.kGroup")) -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; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performGroup.kGroupOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "Group" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string assembleCmd () { // Retrieve the option settings // setOptionVars (false); string $cmd = ("doGroup " + `optionVar -query groupWorld` + " " + `optionVar -query groupPreserve` + " " + `optionVar -query groupZeroPivot` ); return $cmd; } global proc string performGroup (int $action) // The action variable means // 0 - do the command // 1 - show the option box // 2 - return the drag command // { string $cmd = ""; switch ($action) { case 0: // Execute the command // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; // Execute the command with the option settings evalEcho($cmd); break; case 1: // Do the option box groupOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }