// =========================================================================== // 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: 18 January, 2001 // // // Description: // Option box for subdivision surfaces extract // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // // Note: // Commented out Type option for this rev // proc setOptionVars(int $forceFactorySettings) { // Original Object // if ($forceFactorySettings || !`optionVar -exists subdToNurbsOrigObject`) { optionVar -intValue subdToNurbsOrigObject 1; } if ($forceFactorySettings || !`optionVar -exists subdToNurbsOutputType`) { optionVar -intValue subdToNurbsOutputType 0; } } // // Procedure Name: // subdToNurbsSetup // // 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 subdToNurbsSetup(string $parent, int $forceFactorySettings) { int $method; // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. int $outputType = `optionVar -query subdToNurbsOutputType`+1; radioButtonGrp -edit -select $outputType subdToNurbsOutputTypeRadioButtonGrp; // Original Object int $origObject = `optionVar -query subdToNurbsOrigObject`; radioButtonGrp -edit -select $origObject subdToNurbsOrigObjectWidget; } // // Procedure Name: // subdToNurbsCallback // // 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 subdToNurbsCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. optionVar -intValue subdToNurbsOrigObject `radioButtonGrp -q -select subdToNurbsOrigObjectWidget`; int $outputType = `radioButtonGrp -q -select subdToNurbsOutputTypeRadioButtonGrp` -1; optionVar -intValue subdToNurbsOutputType $outputType; if ($doIt) { performSubdToNurbs 0; addToRecentCommandQueue "performSubdToNurbs 0" "Convert"; } } // // Procedure Name: // subdToNurbsOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc subdToNurbsOptions() { // Name of the command for this option box. // string $commandName = "subdToNurbs"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; // Original object // radioButtonGrp -numberOfRadioButtons 3 -label (uiRes("m_performSubdToNurbs.kOriginalObject")) -label1 (uiRes("m_performSubdToNurbs.kReplace")) -label2 (uiRes("m_performSubdToNurbs.kHide")) -label3 (uiRes("m_performSubdToNurbs.kShow")) subdToNurbsOrigObjectWidget; radioButtonGrp -nrb 2 -label (uiRes("m_performSubdToNurbs.kOutputType")) -label1 (uiRes("m_performSubdToNurbs.kNURBS")) -label2 (uiRes("m_performSubdToNurbs.kBeziers")) subdToNurbsOutputTypeRadioButtonGrp; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performSubdToNurbs.kConvert")) -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_performSubdToNurbs.kConvertSubdivOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "SubdivtoNURBS" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // subdToNurbsHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string subdToNurbsHelp() { return " Command: subdivToPoly - convert subdivision surfaces into multiple NURBS.\n" + "Selection: Subdivision surfaces."; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { setOptionVars(false); int $origObject = `optionVar -q subdToNurbsOrigObject`; int $doHistory = `constructionHistory -q -tgl`; int $outputType = `optionVar -query subdToNurbsOutputType`; string $cmd = "doSubdivToNurbs"; $cmd = $cmd + "( {\""; $cmd = $cmd + $doHistory; $cmd = $cmd + "\",\""; $cmd = $cmd + $origObject; $cmd = $cmd + "\",\""; $cmd = $cmd + $outputType; $cmd = $cmd + "\"} )"; return $cmd; } // // Procedure Name: // performSubdToNurbs // // Description: // Perform the performSubdToNurbs 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 performSubdToNurbs 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 performSubdToNurbs(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: subdToNurbsOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }