// =========================================================================== // 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: Sept. 22, 1998 // // Description: // This script defines the option box for the square surface 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 squareSrfPolys`){ optionVar -intValue squareSrfPolys 0; } if ($forceFactorySettings || !`optionVar -exists continuityType`) { optionVar -intValue continuityType 2; } if ($forceFactorySettings || !`optionVar -exists curveFitCheckpoints`) { optionVar -intValue curveFitCheckpoints 5; } if ($forceFactorySettings || !`optionVar -exists squareSrfUseGlobal`) { optionVar -intValue squareSrfUseGlobal 1; } if ($forceFactorySettings || !`optionVar -exists squareSrfTolerance`) { optionVar -floatValue squareSrfTolerance 0.01; } if ($forceFactorySettings || !`optionVar -exists squareSrfRebuild1`){ optionVar -intValue squareSrfRebuild1 0; } if ($forceFactorySettings || !`optionVar -exists squareSrfRebuild2`){ optionVar -intValue squareSrfRebuild2 0; } if ($forceFactorySettings || !`optionVar -exists squareSrfRebuild3`){ optionVar -intValue squareSrfRebuild3 0; } if ($forceFactorySettings || !`optionVar -exists squareSrfRebuild4`){ optionVar -intValue squareSrfRebuild4 0; } if ($forceFactorySettings || !`optionVar -exists squareSrfAutoEdgeCount`) { optionVar -iv squareSrfAutoEdgeCount 4; } } // // Procedure Name: // squareSrfVisibility // // Description: // Depending on the options, some other options do or do not show. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // Return Value: // None. // global proc squareSrfVisibility( string $parent, int $useGlobal, string $goToTool ) { if( $useGlobal < 0 ) { $useGlobal = 2 - `radioButtonGrp -q -select useGlobalRadio`; } radioButtonGrp -e -en 1 useGlobalRadio; if( $useGlobal == 1 ) { floatSliderGrp -e -en 0 toleranceFloat; } else { floatSliderGrp -e -en 1 toleranceFloat; } if( "" != $goToTool ) { checkBoxGrp -e -en1 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget2; } } // // Procedure Name: // squareSurfaceSetup // // 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 squareSurfaceSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars($forceFactorySettings); squareSrfToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls. // Query the optionVar's and set the values into the controls // int $polys = `optionVar -query squareSrfPolys`; int $useGlobal = `optionVar -query squareSrfUseGlobal`; float $tolerance = `optionVar -query squareSrfTolerance`; int $contType = `optionVar -query continuityType`; int $fitCheckpoints = `optionVar -query curveFitCheckpoints`; int $rebuild1 = `optionVar -query squareSrfRebuild1`; int $rebuild2 = `optionVar -query squareSrfRebuild2`; int $rebuild3 = `optionVar -query squareSrfRebuild3`; int $rebuild4 = `optionVar -query squareSrfRebuild4`; radioButtonGrp -edit -select (2 - $useGlobal) useGlobalRadio; floatSliderGrp -edit -value $tolerance toleranceFloat; if ( $contType < 3 ) radioButtonGrp -edit -select $contType contTypeRadio; else radioButtonGrp -edit -select ($contType - 2) contTypeRadio2; intSliderGrp -edit -value $fitCheckpoints numChecksInt; // set polygons | Nurbs option. // if( `isTrue "SurfaceUIExists"` ) { if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) { $polys = 2; } radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp; } switch( $polys ) { 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; } nurbsToPolySetup( $parent, $forceFactorySettings ); nurbsToSubdivSetup( $parent, $forceFactorySettings ); squareSrfVisibility( $parent, $useGlobal, $goToTool ); if ( $contType == 2 ) { // show the controls for the curve fit checkpoints // intSliderGrp -e -en 1 numChecksInt; } else { // dim the controls for the curve fit checkpoints // intSliderGrp -e -en 0 numChecksInt; } // set the rebuild curve options - show all the rebuild curve // options if any one of the check boxes in the group is on // checkBoxGrp -edit -value1 $rebuild1 squareSrfRebuildBox; checkBoxGrp -edit -value2 $rebuild2 squareSrfRebuildBox; checkBoxGrp -edit -value1 $rebuild3 squareSrfRebuildBox2; checkBoxGrp -edit -value2 $rebuild4 squareSrfRebuildBox2; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v1 (4 == `optionVar -q squareSrfAutoEdgeCount`) scriptToolExtraWidget2; } } // // Procedure Name: // squareSurfaceCallback // // 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 squareSurfaceCallback( string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv squareSurfaceEuc `scriptCtx -q -euc $goToTool`; optionVar -iv squareSurfaceLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the current control values, and then perform // the command // int $contType = `radioButtonGrp -q -select contTypeRadio`; if ( $contType == 0 ) { $contType = `radioButtonGrp -q -select contTypeRadio2`; $contType += 2; // to compensate for the 2 radio buttons in // contTypeRadio } int $numChecks = `intSliderGrp -q -value numChecksInt`; int $polys = 1; if( `isTrue "SurfaceUIExists"` ) { $polys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`; if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) { $polys = 4; } } int $useGlobal = 2 - `radioButtonGrp -q -select useGlobalRadio`; float $tolerance = `floatSliderGrp -q -value toleranceFloat`; int $rebuild1 = `checkBoxGrp -q -value1 squareSrfRebuildBox`; int $rebuild2 = `checkBoxGrp -q -value2 squareSrfRebuildBox`; int $rebuild3 = `checkBoxGrp -q -value1 squareSrfRebuildBox2`; int $rebuild4 = `checkBoxGrp -q -value2 squareSrfRebuildBox2`; optionVar -intValue continuityType $contType; optionVar -intValue curveFitCheckpoints $numChecks; optionVar -intValue squareSrfPolys ($polys-1); optionVar -intValue squareSrfUseGlobal $useGlobal; optionVar -floatValue squareSrfTolerance $tolerance; optionVar -intValue squareSrfRebuild1 $rebuild1; optionVar -intValue squareSrfRebuild2 $rebuild2; optionVar -intValue squareSrfRebuild3 $rebuild3; optionVar -intValue squareSrfRebuild4 $rebuild4; nurbsToPolyCallback( $parent, 0 ); nurbsToSubdivCallback( $parent, 0 ); if( 1 == $doIt ) { performSquareSrf( 0, $goToTool ); string $tmpCmd = "performSquareSrf( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Square"; } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // squareSrfOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc squareSrfOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "squareSurface"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Step 1: Get the option box. // ============================ global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolSquareSrf"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "squareSrfToolScript 3"; 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 -nrb 2 -label (uiRes("m_performSquareSrf.kContinuityType")) -label1 (uiRes("m_performSquareSrf.kFixedBoundary")) -da1 1 -label2 (uiRes("m_performSquareSrf.kTangent")) -da2 2 -cc1 ("intSliderGrp -e -en 0 numChecksInt;") -cc2 ("intSliderGrp -e -en 1 numChecksInt;") contTypeRadio; radioButtonGrp -nrb 1 -label "" -scl contTypeRadio -label1 (uiRes("m_performSquareSrf.kImpliedTangent")) -da1 3 -cc1 ("intSliderGrp -e -en 0 numChecksInt;") contTypeRadio2; intSliderGrp -field true -min 1 -max 100 -label (uiRes("m_performSquareSrf.kCurveFitCheckpoints")) numChecksInt; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performSquareSrf.kEndPointTolerance")) -label1 (uiRes("m_performSquareSrf.kGlobal")) -label2 (uiRes("m_performSquareSrf.kLocal")) useGlobalRadio; floatSliderGrp -label (uiRes("m_performSquareSrf.kTolerance")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0 toleranceFloat; // Set the tolerance radio button up so that when "Global" is // selected, then the local tolerance slider is disabled. // When "Local" is selected then the local tolerance slider is enabled. // radioButtonGrp -edit -cc1 ("squareSrfVisibility " + $parent + " 1 \"" + $goToTool + "\"") -cc2 ("squareSrfVisibility " + $parent + " 0 \"" + $goToTool + "\"") useGlobalRadio; checkBoxGrp -ncb 2 -label (uiRes("m_performSquareSrf.kRebuild")) -label1 (uiRes("m_performSquareSrf.kCurve1")) -label2 (uiRes("m_performSquareSrf.kCurve2")) squareSrfRebuildBox; checkBoxGrp -ncb 2 -label "" -label1 (uiRes("m_performSquareSrf.kCurve3")) -label2 (uiRes("m_performSquareSrf.kCurve4")) squareSrfRebuildBox2; separator; // output Geometry // string $outputGeometry = (uiRes("m_performSquareSrf.kOutputGeometry")); string $nurbs = (uiRes("m_performSquareSrf.kNurbs")); string $polygons = (uiRes("m_performSquareSrf.kPolygons")); string $bezier = (uiRes("m_performSquareSrf.kBezier")); if( `isTrue "SubdivUIExists"` ) { radioButtonGrp -nrb 4 -label $outputGeometry -label1 $nurbs -label2 $polygons -label3 (uiRes("m_performSquareSrf.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 { 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; } tabLayout -tabsVisible false polyOptions; string $par = `columnLayout polyOptionsOK`; nurbsToPolyAddOptions $par; setParent ..; setParent ..; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performSquareSrf.kToolBehavior")) -label1 (uiRes("m_performSquareSrf.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performSquareSrf.kAutoCompletion")) -v2 on -on2 ("squareSrfAutoComplete 1 " + "\"" + $goToTool + "\";" + "squareSrfVisibility " + $parent + " -1 \"" + $goToTool + "\"") -of2 ("squareSrfAutoComplete 0 " + "\"" + $goToTool + "\";" + "squareSrfVisibility " + $parent + " -1 \"" + $goToTool + "\"") scriptToolExtraWidget; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performSquareSrf.kBoundaryCurves")) -v1 off -on1 ("squareSrf4curves 4 " + $goToTool + "; optionVar -iv squareSrfAutoEdgeCount 4") -of1 ("squareSrf4curves 3 " + $goToTool + "; optionVar -iv squareSrfAutoEdgeCount 3") scriptToolExtraWidget2; } // 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_performSquareSrf.kSquareSurfaceTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"" ) $applyBtn; } else { button -edit -label (uiRes("m_performSquareSrf.kSquareSurface")) -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_performSquareSrf.kSquareSurfaceToolOptions")); } else { setOptionBoxTitle (uiRes("m_performSquareSrf.kSquareSurfaceOptions")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "Square" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // squareSrfHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string squareSrfHelp() { return " Command: SquareSurface - create a square surface from 3 or 4 curves.\n" + "Selection: curves, surface isoparms, curve on surface, surface edges"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd = "squareSrfPreset"; setOptionVars(false); int $doHistory = `constructionHistory -q -tgl`; int $contType = `optionVar -q continuityType`; int $numChecks = `optionVar -q curveFitCheckpoints`; int $polys = `optionVar -q squareSrfPolys`; int $useGlobal = `optionVar -q squareSrfUseGlobal`; float $globalTol = `optionVar -q positionalTolerance`; float $localTol = `optionVar -q squareSrfTolerance`; int $rebuild1 = `optionVar -q squareSrfRebuild1`; int $rebuild2 = `optionVar -q squareSrfRebuild2`; int $rebuild3 = `optionVar -q squareSrfRebuild3`; int $rebuild4 = `optionVar -q squareSrfRebuild4`; $cmd = ( $cmd + " " + $doHistory + " " + $contType + " " + $numChecks + " " + $polys + " " + $rebuild1 + " " + $rebuild2 + " " + $rebuild3 + " " + $rebuild4 + " " + $useGlobal + " " + $globalTol + " " + $localTol ); return $cmd; } // // Procedure Name: // performSquareSrf // // Description: // Perform the squareSurface 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 squareSurface command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // 3 - Show the tool option box dialog. // // Return Value: // None. // global proc string performSquareSrf( 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: squareSrfOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }