// =========================================================================== // 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: 6 May 1997 // // Description: // This script defines the option box for the NURBS plane menu item. // // // 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 nurbsPlanePivotType`) { optionVar -intValue nurbsPlanePivotType 1; } if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotX`) { optionVar -floatValue nurbsPlanePivotX 0.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotY`) { optionVar -floatValue nurbsPlanePivotY 0.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotZ`) { optionVar -floatValue nurbsPlanePivotZ 0.0; } string $isitYup = `upAxis -q -ax`; if( "y" == $isitYup ) { if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisType`) { optionVar -intValue nurbsPlaneAxisType 2; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisX`) { optionVar -floatValue nurbsPlaneAxisX 0.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisY`) { optionVar -floatValue nurbsPlaneAxisY 1.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisZ`) { optionVar -floatValue nurbsPlaneAxisZ 0.0; } } else { if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisType`) { optionVar -intValue nurbsPlaneAxisType 3; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisX`) { optionVar -floatValue nurbsPlaneAxisX 0.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisY`) { optionVar -floatValue nurbsPlaneAxisY 0.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisZ`) { optionVar -floatValue nurbsPlaneAxisZ 1.0; } } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneWidth`) { optionVar -floatValue nurbsPlaneWidth 1.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneLengthRatio`) { optionVar -floatValue nurbsPlaneLengthRatio 1.0; } if ($forceFactorySettings || !`optionVar -exists nurbsPlaneDegree`) { optionVar -intValue nurbsPlaneDegree 3; } if ($forceFactorySettings || !`optionVar -exists nurbsPlanePatchesU`) { optionVar -intValue nurbsPlanePatchesU 1; } if ($forceFactorySettings || !`optionVar -exists nurbsPlanePatchesV`) { optionVar -intValue nurbsPlanePatchesV 1; } } // // Procedure Name: // nurbsPlaneSetup // // 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 nurbsPlaneSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // Pivot // int $pivotType = `optionVar -q nurbsPlanePivotType`; float $pivotX = `optionVar -q nurbsPlanePivotX`; float $pivotY = `optionVar -q nurbsPlanePivotY`; float $pivotZ = `optionVar -q nurbsPlanePivotZ`; if ($pivotType == 1) { $pivotX = 0; $pivotY = 0; $pivotZ = 0; } radioButtonGrp -e -select $pivotType nurbsPlanePivotType; floatFieldGrp -e -v1 $pivotX -v2 $pivotY -v3 $pivotZ nurbsPlanePivot; // Axis // int $axisType = `optionVar -q nurbsPlaneAxisType`; float $axis[3]; switch($axisType) { case 1: $axis[0] = 1; $axis[1] = 0; $axis[2] = 0; break; case 2: $axis[0] = 0; $axis[1] = 1; $axis[2] = 0; break; case 3: $axis[0] = 0; $axis[1] = 0; $axis[2] = 1; break; case 4: $axis[0] = `optionVar -q nurbsPlaneAxisX`; $axis[1] = `optionVar -q nurbsPlaneAxisY`; $axis[2] = `optionVar -q nurbsPlaneAxisZ`; break; case 5: $axis = `nurbsViewDirectionVector 1`; break; } if( $axisType < 4 ) { radioButtonGrp -e -select $axisType nurbsPlaneAxisType1; } else { radioButtonGrp -e -select ($axisType - 3) nurbsPlaneAxisType2; } floatFieldGrp -e -v1 $axis[0] -v2 $axis[1] -v3 $axis[2] nurbsPlaneAxis; // Width // float $planeWidth = `optionVar -q nurbsPlaneWidth`; floatSliderGrp -e -v $planeWidth nurbsPlaneWidth; // Length Ratio // float $ratio = `optionVar -q nurbsPlaneLengthRatio`; floatSliderGrp -e -v `nurbsRatioConvert $planeWidth $ratio false` nurbsPlaneLength; // Degree // int $degree = `optionVar -q nurbsPlaneDegree`; int $degreeBtn; switch($degree) { case 1: radioButtonGrp -e -select 1 nurbsPlaneDegree123; break; case 2: radioButtonGrp -e -select 2 nurbsPlaneDegree123; break; case 3: radioButtonGrp -e -select 3 nurbsPlaneDegree123; break; case 5: radioButtonGrp -e -select 1 nurbsPlaneDegree57; break; case 7: radioButtonGrp -e -select 2 nurbsPlaneDegree57; break; default: radioButtonGrp -e -select 3 nurbsPlaneDegree123; break; } // Patches U // intSliderGrp -e -v `optionVar -q nurbsPlanePatchesU` nurbsPlanePatchesU; // Patches V // intSliderGrp -e -v `optionVar -q nurbsPlanePatchesV` nurbsPlanePatchesV; // Disable or enable some controls depending on other values. // if ($pivotType == 2) floatFieldGrp -e -enable 1 nurbsPlanePivot; else floatFieldGrp -e -enable 0 nurbsPlanePivot; if ($axisType == 4) floatFieldGrp -e -enable 1 nurbsPlaneAxis; else floatFieldGrp -e -enable 0 nurbsPlaneAxis; } // // Procedure Name: // nurbsPlaneCallback // // 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 nurbsPlaneCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // Pivot // int $pivotType = `radioButtonGrp -q -select nurbsPlanePivotType`; optionVar -intValue nurbsPlanePivotType $pivotType; if ($pivotType == 2) { optionVar -floatValue nurbsPlanePivotX `floatFieldGrp -q -v1 nurbsPlanePivot`; optionVar -floatValue nurbsPlanePivotY `floatFieldGrp -q -v2 nurbsPlanePivot`; optionVar -floatValue nurbsPlanePivotZ `floatFieldGrp -q -v3 nurbsPlanePivot`; } // Axis // int $axisType = `radioButtonGrp -q -select nurbsPlaneAxisType1`; if( 0 == $axisType ) { $axisType = `radioButtonGrp -q -select nurbsPlaneAxisType2` + 3; } optionVar -intValue nurbsPlaneAxisType $axisType; if( ($axisType == 4) || (5 == $axisType) ) { optionVar -floatValue nurbsPlaneAxisX `floatFieldGrp -q -v1 nurbsPlaneAxis`; optionVar -floatValue nurbsPlaneAxisY `floatFieldGrp -q -v2 nurbsPlaneAxis`; optionVar -floatValue nurbsPlaneAxisZ `floatFieldGrp -q -v3 nurbsPlaneAxis`; } // Width // float $planeWidth = `floatSliderGrp -q -v nurbsPlaneWidth`; optionVar -floatValue nurbsPlaneWidth $planeWidth; // Length Ratio // float $ratio = `floatSliderGrp -q -v nurbsPlaneLength`; optionVar -floatValue nurbsPlaneLengthRatio `nurbsRatioConvert $planeWidth $ratio true`; // Degree // int $degreeBtn123 = `radioButtonGrp -q -select nurbsPlaneDegree123`; int $degreeBtn57 = `radioButtonGrp -q -select nurbsPlaneDegree57`; int $degree; switch($degreeBtn123) { case 1: $degree = 1; break; case 2: $degree = 2; break; case 3: $degree = 3; break; default: switch($degreeBtn57) { case 1: $degree = 5; break; case 2: $degree = 7; break; default: $degree = 3; break; } break; } optionVar -intValue nurbsPlaneDegree $degree; // Patches U // optionVar -intValue nurbsPlanePatchesU `intSliderGrp -q -v nurbsPlanePatchesU`; // Patches V // optionVar -intValue nurbsPlanePatchesV `intSliderGrp -q -v nurbsPlanePatchesV`; if ($doIt) { performNurbsPlane 0; addToRecentCommandQueue "performNurbsPlane 0" "NURBS Plane"; } } // // Procedure Name: // nurbsPlaneOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc nurbsPlaneOptions() { // Name of the command for this option box. // string $commandName = "nurbsPlane"; // 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; // Turn on the wait cursor. // waitCursor -state 1; // STEP 4: Create option box contents. // =================================== // tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; radioButtonGrp -label (uiRes("m_performNurbsPlane.kPivot")) -numberOfRadioButtons 2 -label1 (uiRes("m_performNurbsPlane.kObject")) -label2 (uiRes("m_performNurbsPlane.kUserDefined")) -select 1 nurbsPlanePivotType; floatFieldGrp -label (uiRes("m_performNurbsPlane.kPivotPoint")) -numberOfFields 3 nurbsPlanePivot; radioButtonGrp -label (uiRes("m_performNurbsPlane.kAxis")) -numberOfRadioButtons 3 -label1 (uiRes("m_performNurbsPlane.kX")) -label2 (uiRes("m_performNurbsPlane.kY")) -label3 (uiRes("m_performNurbsPlane.kZ")) -select 1 nurbsPlaneAxisType1; radioButtonGrp -numberOfRadioButtons 2 -label1 (uiRes("m_performNurbsPlane.kFree")) -label2 (uiRes("m_performNurbsPlane.kActiveView")) -scl "nurbsPlaneAxisType1" nurbsPlaneAxisType2; floatFieldGrp -label (uiRes("m_performNurbsPlane.kAxisDefinition")) -numberOfFields 3 nurbsPlaneAxis; separator; floatSliderGrp -label (uiRes("m_performNurbsPlane.kWidth")) -fmn 0.0001 -min 0.0001 -fmx 1000 -max 100 nurbsPlaneWidth; floatSliderGrp -label (uiRes("m_performNurbsPlane.kLength")) -fmn 0 -min 0 -fmx 1000 -max 100 nurbsPlaneLength; radioButtonGrp -label (uiRes("m_performNurbsPlane.kSurfaceDegree")) -numberOfRadioButtons 3 -label1 (uiRes("m_performNurbsPlane.kOption1Linear")) -label2 (uiRes("m_performNurbsPlane.kOption2")) // Quadratic -label3 (uiRes("m_performNurbsPlane.kOption3Cubic")) -select 3 nurbsPlaneDegree123; radioButtonGrp -shareCollection nurbsPlaneDegree123 -numberOfRadioButtons 2 -label1 (uiRes("m_performNurbsPlane.kOption5")) // Quintic -label2 (uiRes("m_performNurbsPlane.kOption7")) nurbsPlaneDegree57; intSliderGrp -label (uiRes("m_performNurbsPlane.kUPatches")) -field true -min 1 -fmx 500 -max 100 nurbsPlanePatchesU; intSliderGrp -label (uiRes("m_performNurbsPlane.kVPatches")) -field true -min 1 -fmx 500 -max 100 nurbsPlanePatchesV; // Set the pivot float fields to only be enabled when "Pivot" is "User Defined" // string $pivotEnable = ("floatFieldGrp -e -en 1 nurbsPlanePivot;" + "floatFieldGrp -e" + " -v1 `optionVar -q nurbsPlanePivotX`" + " -v2 `optionVar -q nurbsPlanePivotY`" + " -v3 `optionVar -q nurbsPlanePivotZ`" + " nurbsPlanePivot;" ); string $pivotDisable = "floatFieldGrp -e -en 0 nurbsPlanePivot;"; radioButtonGrp -edit -cc1 ($pivotDisable + "floatFieldGrp -e -value 0.0 0.0 0.0 0.0 nurbsPlanePivot;") -cc2 $pivotEnable nurbsPlanePivotType; // Set the axis float fields to only be enabled when "Axis Preset" is "Free" // string $axisEnable = ("floatFieldGrp -e -en 1 nurbsPlaneAxis;" + "floatFieldGrp -e" + " -v1 `optionVar -q nurbsPlaneAxisX`" + " -v2 `optionVar -q nurbsPlaneAxisY`" + " -v3 `optionVar -q nurbsPlaneAxisZ`" + " nurbsPlaneAxis;" ); string $axisDisable = "floatFieldGrp -e -en 0 nurbsPlaneAxis;"; radioButtonGrp -edit -cc1 ($axisDisable + "floatFieldGrp -e -value 1.0 0.0 0.0 0.0 nurbsPlaneAxis;") -cc2 ($axisDisable + "floatFieldGrp -e -value 0.0 1.0 0.0 0.0 nurbsPlaneAxis;") -cc3 ($axisDisable + "floatFieldGrp -e -value 0.0 0.0 1.0 0.0 nurbsPlaneAxis;") nurbsPlaneAxisType1; radioButtonGrp -edit -cc1 $axisEnable -cc2 $axisDisable nurbsPlaneAxisType2; // 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. // Disable those buttons that are not applicable to the option box. // Attach actions to those buttons that are applicable to the option box. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performNurbsPlane.kCreate")) -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_performNurbsPlane.kNURBSPlaneOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "NurbsPlane" ); // Set the current values of the option box. // ========================================= // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // ==================== // showOptionBox(); } // // Procedure Name: // nurbsPlaneHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string nurbsPlaneHelp() { return " Command: nurbsPlane - create a NURBS plane.\n"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "nurbsPlane"; setOptionVars(false); int $pivotType = `optionVar -q nurbsPlanePivotType`; float $pivotX = `optionVar -q nurbsPlanePivotX`; float $pivotY = `optionVar -q nurbsPlanePivotY`; float $pivotZ = `optionVar -q nurbsPlanePivotZ`; if ($pivotType == 1) { $pivotX = 0; $pivotY = 0; $pivotZ = 0; } // Axis // int $axisType = `optionVar -q nurbsPlaneAxisType`; float $axis[3]; switch($axisType) { case 1: $axis[0] = 1; $axis[1] = 0; $axis[2] = 0; break; case 2: $axis[0] = 0; $axis[1] = 1; $axis[2] = 0; break; case 3: $axis[0] = 0; $axis[1] = 0; $axis[2] = 1; break; case 4: $axis[0] = `optionVar -q nurbsPlaneAxisX`; $axis[1] = `optionVar -q nurbsPlaneAxisY`; $axis[2] = `optionVar -q nurbsPlaneAxisZ`; break; case 5: $axis = `nurbsViewDirectionVector 1`; break; } // History // int $doHistory = `constructionHistory -q -toggle`; $cmd = ($cmd + " -p " + $pivotX + " " + $pivotY + " " + $pivotZ + " -ax " + $axis[0] + " " + $axis[1] + " " + $axis[2] + " -w " + `optionVar -query nurbsPlaneWidth` + " -lr " + `optionVar -query nurbsPlaneLengthRatio` + " -d " + `optionVar -query nurbsPlaneDegree` + " -u " + `optionVar -query nurbsPlanePatchesU` + " -v " + `optionVar -query nurbsPlanePatchesV` + " -ch " + $doHistory + "; objectMoveCommand"); if(`optionVar -q createNurbsPrimitiveAsTool`) { $cmd = "setToolTo \"CreateNurbsPlaneCtx\""; } return $cmd; } // // Procedure Name: // performNurbsPlane // // Description: // Perform the nurbsPlane 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 nurbsPlane command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performNurbsPlane(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: if(`optionVar -q createNurbsPrimitiveAsTool`) { $cmd = `assembleCmd`; evalEcho($cmd); toolPropertyWindow; } else { nurbsPlaneOptions; } break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }