// =========================================================================== // 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 loft 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 loftUniform`) { optionVar -intValue loftUniform 1; } if ($forceFactorySettings || !`optionVar -exists loftClose`) { optionVar -intValue loftClose 0; } if ($forceFactorySettings || !`optionVar -exists loftAutoReverse`) { optionVar -intValue loftAutoReverse 1; } if ($forceFactorySettings || !`optionVar -exists loftDegree`) { optionVar -intValue loftDegree 3; } if( $forceFactorySettings || !`optionVar -exists loftRange`) { optionVar -intValue loftRange 0; } if( $forceFactorySettings || !`optionVar -exists loftPolys`) { optionVar -intValue loftPolys 0; } if( $forceFactorySettings || !`optionVar -exists loftSectionSpans`) { optionVar -intValue loftSectionSpans 1; } } // // Procedure Name: // loftSetup // // 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 loftSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); loftToolSetup( $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 $uniform = `optionVar -query loftUniform`; int $autoReverse = `optionVar -query loftAutoReverse`; int $close = `optionVar -query loftClose`; int $degree = `optionVar -query loftDegree`; int $range = `optionVar -query loftRange`; int $polys = `optionVar -q loftPolys`; int $spans = `optionVar -query loftSectionSpans`; if( ! `isTrue "SurfaceUIExists"` ) $polys = 1; // Set the controls // radioButtonGrp -edit -select (2 - $uniform) uniformRadio; checkBoxGrp -edit -value1 $autoReverse autoReverseCloseCheck; checkBoxGrp -edit -value2 $close autoReverseCloseCheck; if( 3 == $degree ) radioButtonGrp -edit -select 2 degreeRadio; else radioButtonGrp -edit -select 1 degreeRadio; radioButtonGrp -edit -select ($range + 1) rangeRadio; if( `isTrue "SurfaceUIExists"` ) { if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) { $polys = 2; } radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp; } intSliderGrp -e -v $spans sectionSpansInt; 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; } if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } nurbsToPolySetup( $parent, $forceFactorySettings ); nurbsToSubdivSetup( $parent, $forceFactorySettings ); } // // Procedure Name: // loftCallback // // 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 loftCallback(string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv loftEuc `scriptCtx -q -euc $goToTool`; optionVar -iv loftLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the current control values, and then perform // the command // int $uniform = 2 - `radioButtonGrp -q -select uniformRadio`; int $autoReverse = `checkBoxGrp -query -v1 autoReverseCloseCheck`; int $close = `checkBoxGrp -query -v2 autoReverseCloseCheck`; int $degree = `radioButtonGrp -q -select degreeRadio`; int $spans = `intSliderGrp -q -v sectionSpansInt`; if( 1 != $degree ) $degree = 3; int $range = `radioButtonGrp -q -select rangeRadio` - 1; if( `isTrue "SurfaceUIExists"` ) { int $polygons = `radioButtonGrp -q -select outputPolyRadioButtonGrp`; if( (3 == $polygons) && ! `isTrue "SubdivUIExists"` ) { $polygons = 4; } optionVar -intValue loftPolys ($polygons-1); } optionVar -intValue loftUniform $uniform; optionVar -intValue loftClose $close; optionVar -intValue loftAutoReverse $autoReverse; optionVar -intValue loftDegree $degree; optionVar -intValue loftRange $range; optionVar -intValue loftSectionSpans $spans; nurbsToPolyCallback( $parent, 0 ); nurbsToSubdivCallback( $parent, 0 ); if( 1 == $doIt ) { performLoft( 0, $goToTool ); string $tmpCmd = "performLoft(0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Loft"; } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // loftOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc loftOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "loft"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Step 1: Get the option box. // ============================ global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolLoft"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "loftToolScript 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 -numberOfRadioButtons 2 -label (uiRes("m_performLoft.kParameterization")) -label1 (uiRes("m_performLoft.kUniform")) -label2 (uiRes("m_performLoft.kChordLength")) uniformRadio; checkBoxGrp -ncb 2 -label1 (uiRes("m_performLoft.kAutoReverse")) -label2 (uiRes("m_performLoft.kClose")) autoReverseCloseCheck; radioButtonGrp -nrb 2 -label (uiRes("m_performLoft.kSurfaceDegree")) -label1 (uiRes("m_performLoft.kLinear")) -label2 (uiRes("m_performLoft.kCubic")) degreeRadio; intSliderGrp -label (uiRes("m_performLoft.kSectionSpans")) -min 1 -max 10 -fmn 1 -fmx 500 sectionSpansInt; separator; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performLoft.kCurveRange")) -label1 (uiRes("m_performLoft.kComplete")) -label2 (uiRes("m_performLoft.kPartial")) rangeRadio; string $outputGeometry = (uiRes("m_performLoft.kOutputGeometry")); string $nurbs = (uiRes("m_performLoft.kNurbs")); string $polygons = (uiRes("m_performLoft.kPolygons")); string $bezier = (uiRes("m_performLoft.kBezier")); if( `isTrue "SubdivUIExists"` ) { radioButtonGrp -nrb 4 -label $outputGeometry -label1 $nurbs -label2 $polygons -label3 (uiRes("m_performLoft.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; } separator; tabLayout -tabsVisible false polyOptions; string $par = `columnLayout polyOptionsOK`; nurbsToPolyAddOptions $par; setParent ..; setParent ..; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performLoft.kToolBehavior")) -label1 (uiRes("m_performLoft.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performLoft.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_performLoft.kLoftTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performLoft.kLoft")) -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_performLoft.kLoftToolOptions")); } else { setOptionBoxTitle (uiRes("m_performLoft.kLoftOptions")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "Loft" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // loftHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string loftHelp() { return " Command: Loft - loft a number of curves (or add to lofted surface)\n" + "Selection: curve, curve on surface, surface isoparm"; } // // 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 = "doPerformLoft"; setOptionVars(false); int $history = `constructionHistory -q -tgl`; int $uniform = `optionVar -q loftUniform`; int $autoReverse = `optionVar -q loftAutoReverse`; int $close = `optionVar -q loftClose`; int $degree = `optionVar -q loftDegree`; int $spans = `optionVar -q loftSectionSpans`; int $range = `optionVar -q loftRange`; int $polys = `optionVar -q loftPolys`; if( ! `isTrue "SurfaceUIExists"` ) $polys = 1; $cmd = $cmd + "("; $cmd = $cmd + "\"1\"" + ", {"; $cmd = $cmd + "\"" + $history + "\","; $cmd = $cmd + "\"" + $uniform + "\","; $cmd = $cmd + "\"" + $autoReverse + "\","; $cmd = $cmd + "\"" + $close + "\","; $cmd = $cmd + "\"" + $degree + "\","; $cmd = $cmd + "\"" + $spans + "\","; $cmd = $cmd + "\"" + $range + "\","; $cmd = $cmd + "\"" + $polys + "\""; $cmd = $cmd + "} )"; return $cmd; } // // Procedure Name: // performLoft // // Description: // Perform the loft 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 loft 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 performLoft(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: loftOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }