// =========================================================================== // 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: Mar 14, 1997 // // // Description: // This script is defines the option box for the revolve menu item. // // Input Arguments: // int showOptionBox true - show the option box dialog // false - just execute the revolve operation // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { revolveSetOptionVars( $forceFactorySettings ); } global proc revolveSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); revolveToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query all of the optionVar's // int $usePresetAxis = `optionVar -q revolveUsePresetAxis` + 1; float $axisX, $axisY, $axisZ; switch( $usePresetAxis ) { case 1: $axisX = 1; $axisY = 0; $axisZ = 0; break; case 2: $axisX = 0; $axisY = 1; $axisZ = 0; break; case 3: $axisX = 0; $axisY = 0; $axisZ = 1; break; case 4: $axisX = `optionVar -q revolveAxisX`; $axisY = `optionVar -q revolveAxisY`; $axisZ = `optionVar -q revolveAxisZ`; break; } int $useObjectPivot = `optionVar -q revolveUseLocalPivot`; float $pivotX, $pivotY, $pivotZ; if( $useObjectPivot ) { $pivotX = 0; $pivotY = 0; $pivotZ = 0; } else { $pivotX = `optionVar -q revolvePivotX`; $pivotY = `optionVar -q revolvePivotY`; $pivotZ = `optionVar -q revolvePivotZ`; } float $startSweep = `optionVar -q revolveStartSweepAngle`; float $endSweep = `optionVar -q revolveEndSweepAngle`; int $degree = `optionVar -q revolveSurfaceDegree`; switch( $degree ) { case 1: $degree = 1; break; // used below for degreeRadioButtonGrp case 3: $degree = 2; break; // used below for degreeRadioButtonGrp } int $useTol = `optionVar -q revolveUseTolerance`; int $useGlobalTol = `optionVar -q revolveUseGlobalTol`; float $tol = `optionVar -q revolveTolerance`; int $numSegments = `optionVar -q revolveNumberOfSegments`; int $partialCrvRange = `optionVar -q revolveCurveRangePartial` + 1; int $outputPolys = `optionVar -q revolveOutputPolygons`; if( ! `isTrue "SurfaceUIExists"` ) $outputPolys = 1; // Set the controls // radioButtonGrp -edit -select $usePresetAxis presetAxisRadioGroup; radioButtonGrp -edit -select (2 - $useObjectPivot) pivotPointRadioGroup; floatFieldGrp -edit -v1 $axisX axisFloatFieldGrp; floatFieldGrp -edit -v2 $axisY axisFloatFieldGrp; floatFieldGrp -edit -v3 $axisZ axisFloatFieldGrp; floatFieldGrp -edit -v1 $pivotX pivotFloatFieldGrp; floatFieldGrp -edit -v2 $pivotY pivotFloatFieldGrp; floatFieldGrp -edit -v3 $pivotZ pivotFloatFieldGrp; floatSliderGrp -edit -value $startSweep startSweepFloatSliderGrp; floatSliderGrp -edit -value $endSweep endSweepFloatSliderGrp; radioButtonGrp -edit -select $degree degreeRadioButtonGrp; intSliderGrp -edit -value $numSegments segmentsIntSliderGrp; if( $useTol ) { if( $useGlobalTol ) { radioButtonGrp -edit -select 3 useTolerance; } else { radioButtonGrp -edit -select 2 useTolerance; } } else { radioButtonGrp -edit -select 1 useTolerance; } floatSliderGrp -edit -value $tol toleranceFloatFieldGrp; radioButtonGrp -edit -select $partialCrvRange curveRangeRadioButtonGrp; if( `isTrue "SurfaceUIExists"` ) { if( (3 == $outputPolys) && ! `isTrue "SubdivUIExists"` ) { $outputPolys = 2; } radioButtonGrp -edit -select ($outputPolys+1) outputPolyRadioButtonGrp; } // Disable and enable some sliders depending on other values // if( $usePresetAxis == 4 ) floatFieldGrp -e -enable 1 axisFloatFieldGrp; else floatFieldGrp -e -enable 0 axisFloatFieldGrp; if( $useObjectPivot == 0 ) floatFieldGrp -e -enable 1 pivotFloatFieldGrp; else floatFieldGrp -e -enable 0 pivotFloatFieldGrp; if( $useTol ) { if( $useGlobalTol ) { tabLayout -e -vis false tlTolerance; } else { tabLayout -e -vis true -selectTab useToleranceSlider tlTolerance; } } else { tabLayout -e -vis true -selectTab useToleranceNoSlider tlTolerance; } switch( $outputPolys ) { case 0: default: tabLayout -e -vis false polyOptions; // there are currently no NURBS options break; case 1: tabLayout -e -vis true polyOptions; break; case 2: tabLayout -e -vis false polyOptions; // there are currently no subdiv options break; case 3: tabLayout -e -vis false polyOptions; // there are currently no bezier options break; } if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } nurbsToPolySetup( $parent, $forceFactorySettings ); nurbsToSubdivSetup( $parent, $forceFactorySettings ); } global proc revolveCallback( string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv revolveEuc `scriptCtx -q -euc $goToTool`; optionVar -iv revolveLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Get all the values from the controls // int $usePresetAxis = `radioButtonGrp -q -select presetAxisRadioGroup` - 1; int $useObjectPivot = 2 - `radioButtonGrp -q -select pivotPointRadioGroup`; float $axisX = `floatFieldGrp -q -v1 axisFloatFieldGrp`; float $axisY = `floatFieldGrp -q -v2 axisFloatFieldGrp`; float $axisZ = `floatFieldGrp -q -v3 axisFloatFieldGrp`; float $pivotX = `floatFieldGrp -q -v1 pivotFloatFieldGrp`; float $pivotY = `floatFieldGrp -q -v2 pivotFloatFieldGrp`; float $pivotZ = `floatFieldGrp -q -v3 pivotFloatFieldGrp`; float $startSw = `floatSliderGrp -q -value startSweepFloatSliderGrp`; float $endSw = `floatSliderGrp -q -value endSweepFloatSliderGrp`; int $degree = `radioButtonGrp -q -select degreeRadioButtonGrp`; if( $degree == 1 ) $degree = 1; else $degree = 3; int $segments = `intSliderGrp -q -value segmentsIntSliderGrp`; int $valUse = `radioButtonGrp -q -select useTolerance`; switch( $valUse ) { case 1: optionVar -intValue revolveUseTolerance false; break; case 2: optionVar -intValue revolveUseTolerance true; optionVar -intValue revolveUseGlobalTol false; break; case 3: default: optionVar -intValue revolveUseTolerance true; optionVar -intValue revolveUseGlobalTol true; break; } float $tol = `floatSliderGrp -q -value toleranceFloatFieldGrp`; int $useCrvRange = `radioButtonGrp -q -select curveRangeRadioButtonGrp` -1; if( `isTrue "SurfaceUIExists"` ) { int $outputPolys; $outputPolys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`; if( (3 == $outputPolys) && ! `isTrue "SubdivUIExists"` ) { $outputPolys = 4; } optionVar -intValue revolveOutputPolygons ($outputPolys-1); } // Set all the corresponding option var's // optionVar -intValue revolveUsePresetAxis $usePresetAxis; optionVar -intValue revolveUseLocalPivot $useObjectPivot; if( $usePresetAxis == 3 ) { optionVar -floatValue revolveAxisX $axisX; optionVar -floatValue revolveAxisY $axisY; optionVar -floatValue revolveAxisZ $axisZ; } if( !$useObjectPivot ) { optionVar -floatValue revolvePivotX $pivotX; optionVar -floatValue revolvePivotY $pivotY; optionVar -floatValue revolvePivotZ $pivotZ; } optionVar -floatValue revolveStartSweepAngle $startSw; optionVar -floatValue revolveEndSweepAngle $endSw; optionVar -intValue revolveSurfaceDegree $degree; optionVar -intValue revolveNumberOfSegments $segments; optionVar -floatValue revolveTolerance $tol; optionVar -intValue revolveCurveRangePartial $useCrvRange; nurbsToPolyCallback( $parent, 0 ); nurbsToSubdivCallback( $parent, 0 ); if( 1 == $doIt ) { performRevolve( 0, $goToTool ); string $tmpCmd = "performRevolve( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Revolve"; } else if( $doIt ) { setToolTo $goToTool; } } proc revolveOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "revolve"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolRevolve"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "revolveToolScript 3"; // 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 -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; radioButtonGrp -numberOfRadioButtons 4 -label (uiRes("m_performRevolve.kAxisPreset")) -label1 (uiRes("m_performRevolve.kX")) -label2 (uiRes("m_performRevolve.kY")) -label3 (uiRes("m_performRevolve.kZ")) -label4 (uiRes("m_performRevolve.kFree")) presetAxisRadioGroup; floatFieldGrp -label (uiRes("m_performRevolve.kAxis")) -nf 3 axisFloatFieldGrp; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performRevolve.kPivot")) -label1 (uiRes("m_performRevolve.kObject")) -label2 (uiRes("m_performRevolve.kPreset")) pivotPointRadioGroup; floatFieldGrp -label (uiRes("m_performRevolve.kPivotPoint")) -nf 3 pivotFloatFieldGrp; separator; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performRevolve.kSurfaceDegree")) -label1 (uiRes("m_performRevolve.kLinear")) -label2 (uiRes("m_performRevolve.kCubic")) degreeRadioButtonGrp; floatSliderGrp -label (uiRes("m_performRevolve.kStartSweepAngle")) -min 0 -max 360.0 -field on startSweepFloatSliderGrp; floatSliderGrp -label (uiRes("m_performRevolve.kEndSweepAngle")) -min 0 -max 360.0 -field on endSweepFloatSliderGrp; radioButtonGrp -nrb 3 -label (uiRes("m_performRevolve.kUseTolerance")) -label1 (uiRes("m_performRevolve.kNone")) -label2 (uiRes("m_performRevolve.kLocal")) -label3 (uiRes("m_performRevolve.kGlobal")) useTolerance; tabLayout -tabsVisible false tlTolerance; columnLayout useToleranceNoSlider; intSliderGrp -label (uiRes("m_performRevolve.kSegments")) -min 0 -field on segmentsIntSliderGrp; setParent ..; columnLayout useToleranceSlider; floatSliderGrp -label (uiRes("m_performRevolve.kTolerance")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0 toleranceFloatFieldGrp; setParent ..; setParent ..; separator; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performRevolve.kCurveRange")) -label1 (uiRes("m_performRevolve.kComplete")) -label2 (uiRes("m_performRevolve.kPartial")) curveRangeRadioButtonGrp; string $outputGeometry = (uiRes("m_performRevolve.kOutputGeometry")); string $nurbs = (uiRes("m_performRevolve.kNurbs")); string $polygons = (uiRes("m_performRevolve.kPolygons")); string $bezier = (uiRes("m_performRevolve.kBezier")); if( `isTrue "SubdivUIExists"` ) { radioButtonGrp -nrb 4 -label $outputGeometry -label1 $nurbs -label2 $polygons -label3 (uiRes("m_performRevolve.kSubdiv")) -label4 $bezier -cc1 "tabLayout -e -vis false polyOptions" // there are currently no NURBS options -cc2 "tabLayout -e -vis true polyOptions" -cc3 "tabLayout -e -vis false polyOptions" // there are currently no subdiv options -cc4 "tabLayout -e -vis false polyOptions" // there are currently no bezier options outputPolyRadioButtonGrp; } else if( `isTrue "SurfaceUIExists"` ) { radioButtonGrp -nrb 3 -label $outputGeometry -label1 $nurbs -label2 $polygons -label3 $bezier -cc1 "tabLayout -e -vis false polyOptions" // there are currently no NURBS options -cc2 "tabLayout -e -vis true polyOptions" -cc3 "tabLayout -e -vis false polyOptions" // there are currently no bezier options outputPolyRadioButtonGrp; } // Set the Axis float field grp to display only when Axis Preset is Free // string $enable = "floatFieldGrp -e -en 1 axisFloatFieldGrp;" + "floatFieldGrp -e " + "-value1 `optionVar -q revolveAxisX` " + "-value2 `optionVar -q revolveAxisY` " + "-value3 `optionVar -q revolveAxisZ` axisFloatFieldGrp; "; string $disable = "floatFieldGrp -e -en 0 axisFloatFieldGrp;"; radioButtonGrp -edit -cc1 ($disable + "floatFieldGrp -e -value 1.0 0.0 0.0 0.0 axisFloatFieldGrp;") -cc2 ($disable + "floatFieldGrp -e -value 0.0 1.0 0.0 0.0 axisFloatFieldGrp;") -cc3 ($disable + "floatFieldGrp -e -value 0.0 0.0 1.0 0.0 axisFloatFieldGrp;") -cc4 $enable presetAxisRadioGroup; // Set the Pivot float field grp to display only when Pivot is Global // string $enableP = "floatFieldGrp -e -en 1 pivotFloatFieldGrp;" + "floatFieldGrp -e " + "-value1 `optionVar -q revolvePivotX` " + "-value2 `optionVar -q revolvePivotY` " + "-value3 `optionVar -q revolvePivotZ` pivotFloatFieldGrp;"; string $disableP = "floatFieldGrp -e -en 0 pivotFloatFieldGrp;"; radioButtonGrp -edit -cc1 $disableP -cc2 $enableP pivotPointRadioGroup; // Set the "Use Tolerance" checkbox so that if the checkbox is on, // then the tolerance slider is visible. // radioButtonGrp -edit -on1 ( "tabLayout -e -vis true -selectTab useToleranceNoSlider tlTolerance;" ) -on2 ( "tabLayout -e -vis true -selectTab useToleranceSlider tlTolerance;" ) -on3 ( "tabLayout -e -vis false tlTolerance;" ) useTolerance; separator; tabLayout -tabsVisible false polyOptions; string $par = `columnLayout polyOptionsOK`; nurbsToPolyAddOptions $par; setParent ..; setParent ..; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performRevolve.kToolBehavior")) -label1 (uiRes("m_performRevolve.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performRevolve.kAutoCompletion")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } // 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(); if( $inTheTool ) { button -edit -label (uiRes("m_performRevolve.kRevolveTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performRevolve.kRevolve")) -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"") $applyBtn; } // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " 0 \"" + $goToTool + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"") $resetBtn; // Step 7: Set the option box title. // ================================= // if( $inTheTool ) { setOptionBoxTitle (uiRes("m_performRevolve.kRevolveToolOptions")); } else { setOptionBoxTitle (uiRes("m_performRevolve.kRevolveOptions")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "Revolve" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // revolveHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string revolveHelp() { return " Command: Revolve - create surface from a curve\n" + "Selection: curve, curve on surface, surface isoparm"; } proc string assembleCmd() { setOptionVars( false ); int $usePresetAxis = `optionVar -q revolveUsePresetAxis`; float $axisX, $axisY, $axisZ; switch( $usePresetAxis ) { case 0: $axisX = 1; $axisY = 0; $axisZ = 0; break; case 1: $axisX = 0; $axisY = 1; $axisZ = 0; break; case 2: $axisX = 0; $axisY = 0; $axisZ = 1; break; case 3: $axisX = `optionVar -q revolveAxisX`; $axisY = `optionVar -q revolveAxisY`; $axisZ = `optionVar -q revolveAxisZ`; break; } int $useObjectPivot = `optionVar -q revolveUseLocalPivot`; float $pivotX, $pivotY, $pivotZ; switch( $useObjectPivot ) { case 1: $pivotX = 0; $pivotY = 0; $pivotZ = 0; break; case 0: $pivotX = `optionVar -q revolvePivotX`; $pivotY = `optionVar -q revolvePivotY`; $pivotZ = `optionVar -q revolvePivotZ`; break; } float $startSweep = `optionVar -q revolveStartSweepAngle`; float $endSweep = `optionVar -q revolveEndSweepAngle`; int $degree = `optionVar -q revolveSurfaceDegree`; int $useTol = `optionVar -q revolveUseTolerance`; float $tol = `optionVar -q revolveTolerance`; if( `optionVar -q revolveUseGlobalTol` ) { $tol = `optionVar -q positionalTolerance`; } int $numSegments = `optionVar -q revolveNumberOfSegments`; int $partialCrvRange = `optionVar -q revolveCurveRangePartial`; int $outputPolys = `optionVar -q revolveOutputPolygons`; if( ! `isTrue "SurfaceUIExists"` ) $outputPolys = 1; int $doHistory = `constructionHistory -q -tgl`; // Piece together the revolve command // string $cmd = ( "revolvePreset " + $doHistory + " " + $outputPolys + " " + $partialCrvRange + " " + $startSweep + " " + $endSweep + " " + $useTol + " " + $tol + " " + $degree + " " + $numSegments + " " + $useObjectPivot + " " + $axisX + " " + $axisY + " " + $axisZ + " " + $pivotX + " " + $pivotY + " " + $pivotZ ); return $cmd; } // The action variable means // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // 3 - Show the tool option box dialog. global proc string performRevolve( int $action, string $goToTool ) { int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } string $cmd = ""; switch ($action) { case 0: setOptionVars (false); $cmd = `assembleCmd`; eval($cmd); break; case 1: revolveOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }