// =========================================================================== // 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: January 11, 1997 // // Description: // NURBS Smoothness->Medium option box script. // // Input Arguments: // bool if true show option box // if false perform command with current values // Return Value: // none // // // 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) { // Objects Affected // if ($forceFactorySettings || !`optionVar -exists dispSmthnessMediumNurbsObjsAffected`) { optionVar -intValue dispSmthnessMediumNurbsObjsAffected 1; } } // // Procedure Name: // displaySmoothnessMediumSetup // // 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 displaySmoothnessMediumSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. int $nurbsObjsAffected = `optionVar -q dispSmthnessMediumNurbsObjsAffected`; radioButtonGrp -e -sl $nurbsObjsAffected nurbsObjsAffectedRadio; } // // Procedure Name: // displaySmoothnessMediumCallback // // 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 displaySmoothnessMediumCallback(string $parent, int $doIt) { setParent $parent; int $nurbsObjsAffected = `radioButtonGrp -q -sl nurbsObjsAffectedRadio`; optionVar -intValue dispSmthnessMediumNurbsObjsAffected $nurbsObjsAffected; if ($doIt) { performDisplaySmoothnessMedium 0; addToRecentCommandQueue "performDisplaySmoothnessMedium 0" "DisplaySmoothnessMedium"; } } // // Procedure Name: // displaySmoothnessMediumOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc displaySmoothnessMediumOptions() { // Name of the command for this option box. // string $commandName = "displaySmoothnessMedium"; // 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 - see STEP 8. // ============================================================== // 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`; // Create the first tab radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performDisplaySmoothnessMedium.kObjectsAffected")) -label1 (uiRes("m_performDisplaySmoothnessMedium.kActive")) -label2 (uiRes("m_performDisplaySmoothnessMedium.kAll")) nurbsObjsAffectedRadio; // 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 + " " + $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_performDisplaySmoothnessMedium.kNURBSMediumOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "NURBSSmoothnessMedium" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = ""; int $i; setOptionVars(false); // Work on the NURBS objects // int $nurbsObjsAffected= `optionVar -q dispSmthnessMediumNurbsObjsAffected`; if ($nurbsObjsAffected == 1) { // Change the smoothness of only the active NURBS objects // $cmd = "displaySmoothness -full -du 1 -dv 1 -pw 8 -ps 2;"; } else { // Change the smoothness of all the NURBS objects // string $nurbsObjs[] = `ls -type nurbsSurface -type nurbsCurve`; if (size($nurbsObjs) > 0) { $cmd = "displaySmoothness -full -du 1 -dv 1 -pw 8 -ps 2 "; for ($i = 0; $i < size($nurbsObjs); $i++) { $cmd = $cmd + " " + $nurbsObjs[$i] + " "; } $cmd = $cmd + ";"; } } return $cmd; } // // Procedure Name: // performDisplaySmoothnessMedium // // Description: // Perform the DisplaySmoothnessMedium 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 DisplaySmoothnessMedium command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performDisplaySmoothnessMedium(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: displaySmoothnessMediumOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }