// =========================================================================== // 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: July 24, 1998 // // // Description: // This script is defines the option box for the blend surface menu item. // // Input Arguments: // int action // 0 - just execute the blend operation // 1 - show the option box dialog // 2 - return the script that would do it // 3 - pretend you are a tool instead // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists blendCurvesInFirst` ) { optionVar -intValue blendCurvesInFirst 1; } if( $forceFactorySettings || !`optionVar -exists blendAutoDirection` ) { optionVar -intValue blendAutoDirection 1; } if( $forceFactorySettings || !`optionVar -exists blendAutoAnchor` ) { optionVar -intValue blendAutoAnchor 1; } if( $forceFactorySettings || !`optionVar -exists blendLeftAnchor` ) { optionVar -floatValue blendLeftAnchor 0.0; } if( $forceFactorySettings || !`optionVar -exists blendLeftStart` ) { optionVar -floatValue blendLeftStart 0.0; } if( $forceFactorySettings || !`optionVar -exists blendLeftEnd` ) { optionVar -floatValue blendLeftEnd 1.0; } if( $forceFactorySettings || !`optionVar -exists blendLeftReverse` ) { optionVar -intValue blendLeftReverse 0; } if( $forceFactorySettings || !`optionVar -exists blendRightAnchor` ) { optionVar -floatValue blendRightAnchor 0.0; } if( $forceFactorySettings || !`optionVar -exists blendRightStart` ) { optionVar -floatValue blendRightStart 0.0; } if( $forceFactorySettings || !`optionVar -exists blendRightEnd` ) { optionVar -floatValue blendRightEnd 1.0; } if( $forceFactorySettings || !`optionVar -exists blendRightReverse` ) { optionVar -intValue blendRightReverse 0; } if( $forceFactorySettings || !`optionVar -exists blendMultiKnots` ) { optionVar -intValue blendMultiKnots 0; } if( $forceFactorySettings || !`optionVar -exists blendFlipLeft` ) { optionVar -intValue blendFlipLeft 0; } if( $forceFactorySettings || !`optionVar -exists blendFlipRight` ) { optionVar -intValue blendFlipRight 0; } if( $forceFactorySettings || !`optionVar -exists blendUseLocalTol` ) { optionVar -intValue blendUseLocalTol 1; } if( $forceFactorySettings || !`optionVar -exists blendPositionTol` ) { optionVar -floatValue blendPositionTol 0.1; } if( $forceFactorySettings || !`optionVar -exists blendTangentTol` ) { optionVar -floatValue blendTangentTol 0.1; } if( $forceFactorySettings || !`optionVar -exists blendOutputPoly` ) { optionVar -intValue blendOutputPoly 0; } } global proc blendVisibility( string $parent, int $autoDir, int $useLocal ) { setParent $parent; if( $autoDir < 0 ) { $autoDir = `checkBoxGrp -q -v1 blendAutoDirectionWidget`; } if( $useLocal < 0 ) { $useLocal = `radioButtonGrp -q -select blendUseLocalTolWidget` - 1; } if( $autoDir ) { checkBoxGrp -e -en1 false -en2 false blendFlipWidget; checkBoxGrp -e -en2 true blendAutoDirectionWidget; } else { checkBoxGrp -e -en1 true -en2 true blendFlipWidget; checkBoxGrp -e -en2 false blendAutoDirectionWidget; } if( $useLocal ) { tabLayout -e -vis true tolerancesTab; } else { tabLayout -e -vis false tolerancesTab; } } proc string assembleCmd() // // Description : // To assemble blend proc. // { setOptionVars(false); string $cmd; int $history = `constructionHistory -q -tgl`; int $first = `optionVar -q blendCurvesInFirst`; int $multi = `optionVar -q blendMultiKnots`; int $auto = `optionVar -q blendAutoDirection`; int $flipL = `optionVar -q blendFlipLeft`; int $flipR = `optionVar -q blendFlipRight`; int $poly = `optionVar -q blendOutputPoly`; if( !`isTrue "SurfaceUIExists"` ) $poly = 1; int $useLocal = `optionVar -q blendUseLocalTol`; float $pos = `optionVar -q blendPositionTol`; float $tan = `optionVar -q blendTangentTol`; int $aa = `optionVar -q blendAutoAnchor`; float $la = `optionVar -q blendLeftAnchor`; float $ls = `optionVar -q blendLeftStart`; float $le = `optionVar -q blendLeftEnd`; int $rvl = `optionVar -q blendLeftReverse`; float $ra = `optionVar -q blendRightAnchor`; float $rs = `optionVar -q blendRightStart`; float $re = `optionVar -q blendRightEnd`; int $rvr = `optionVar -q blendRightReverse`; if( !$useLocal ) { $pos = `optionVar -q positionalTolerance`; $tan = `optionVar -q tangentialTolerance`; } $cmd = "doFilletBlendArgList 2 {"; $cmd = $cmd + "\"" + $history + "\", "; $cmd = $cmd + "\"" + $first + "\", "; $cmd = $cmd + "\"" + $auto + "\", "; $cmd = $cmd + "\"" + $flipL + "\", "; $cmd = $cmd + "\"" + $flipR + "\", "; $cmd = $cmd + "\"" + $multi + "\", "; $cmd = $cmd + "\"" + $pos + "\", "; $cmd = $cmd + "\"" + $tan + "\", "; $cmd = $cmd + "\"" + $poly + "\", "; $cmd = $cmd + "\"" + $aa + "\", "; $cmd = $cmd + "\"" + $la + "\", "; $cmd = $cmd + "\"" + $ls + "\", "; $cmd = $cmd + "\"" + $le + "\", "; $cmd = $cmd + "\"" + $rvl + "\", "; $cmd = $cmd + "\"" + $ra + "\", "; $cmd = $cmd + "\"" + $rs + "\", "; $cmd = $cmd + "\"" + $re + "\", "; $cmd = $cmd + "\"" + $rvr + "\" }"; return $cmd; } proc blendOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "blend"; // 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 -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; checkBoxGrp -ncb 2 -label "" -label1 (uiRes("m_performBlend.kAutoNormalDir")) -label2 (uiRes("m_performBlend.kMultipleKnots")) -on1 ("blendVisibility " + $parent + " 1 -1") -of1 ("blendVisibility " + $parent + " 0 -1") blendAutoDirectionWidget; string $left = (uiRes("m_performBlend.kLeft")); string $right = (uiRes("m_performBlend.kRight")); checkBoxGrp -ncb 2 -label (uiRes("m_performBlend.kReverseNormal")) -label1 $left -label2 $right blendFlipWidget; checkBoxGrp -ncb 2 -label (uiRes("m_performBlend.kReverseDirection")) -label1 $left -label2 $right blendReverseWidget; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performBlend.kAutoClosedRailAnchor")) blendAnchorWidget; string $global = (uiRes("m_performBlend.kGlobal")); string $local = (uiRes("m_performBlend.kLocal")); radioButtonGrp -nrb 2 -label (uiRes("m_performBlend.kUseTolerance")) -label1 $global -label2 $local -cc1 ("blendVisibility " + $parent + " -1 0") -cc2 ("blendVisibility " + $parent + " -1 1") blendUseLocalTolWidget; separator; tabLayout -tabsVisible false tolerancesTab; columnLayout localTolerancesTab; floatSliderGrp -label (uiRes("m_performBlend.kPositionalTolerance")) -min 0 -max 1 -fmn 0 -fmx 1 blendPositionTolWidget; floatSliderGrp -label (uiRes("m_performBlend.kTangentialTolerance")) -min 0 -max 1 -fmn 0 -fmx 1 blendTangentTolWidget; setParent ..; setParent ..; separator; string $outputGeometry = (uiRes("m_performBlend.kOutputGeometry")); string $nurbs = (uiRes("m_performBlend.kNurbs")); string $polygons = (uiRes("m_performBlend.kPolygons")); string $bezier = (uiRes("m_performBlend.kBezier")); if( `isTrue "SubdivUIExists"` ) { radioButtonGrp -nrb 4 -label $outputGeometry -label1 $nurbs -da1 0 -label2 $polygons -da2 1 -label3 (uiRes("m_performBlend.kSubdiv")) -da3 2 -label4 $bezier -da4 3 -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 blendOutputPolyWidget; } else if( `isTrue "SurfaceUIExists"` ) { radioButtonGrp -nrb 3 -label $outputGeometry -label1 $nurbs -da1 0 -label2 $polygons -da2 1 -label3 $bezier -da3 2 -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 blendOutputPolyWidget; } tabLayout -tabsVisible false polyOptions; string $par = `columnLayout polyOptionsOK`; nurbsToPolyAddOptions $par; setParent ..; setParent ..; separator; checkBoxGrp -ncb 1 -label (uiRes("m_performBlend.kToolBehavior")) -label1 (uiRes("m_performBlend.kExit")) -v1 on -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc 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_performBlend.kFilletBlendTool")) -command ($callback + " " + $parent + " " + 3 + " " + $goToTool ) $applyBtn; } else { button -edit -label (uiRes("m_performBlend.kBlend")) -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. // ================================= // setOptionBoxTitle (uiRes("m_performBlend.kFilletBlendOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "FilletBlendTool" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0 + " " + $goToTool)); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string blendHelp() { string $cmdHelp = "Command:- create a blend surface \n"; string $selectHelp = ("Selection: One or more profile curves followed " + "by the two rail curves along which to blend."); return $cmdHelp+$selectHelp; } global proc blendSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // retrieve option settings. // setOptionVars( $forceFactorySettings ); if( $forceFactorySettings ) { scriptCtx -e -exitUponCompletion true $goToTool; } setParent $parent; checkBoxGrp -e -v1 `scriptCtx -q -exitUponCompletion $goToTool` scriptToolExtraWidget; // query all the option vars. // int $multi = `optionVar -q blendMultiKnots`; int $auto = `optionVar -q blendAutoDirection`; int $flipL = `optionVar -q blendFlipLeft`; int $flipR = `optionVar -q blendFlipRight`; int $poly = `optionVar -q blendOutputPoly`; if( !`isTrue "SurfaceUIExists"` ) $poly = 1; int $useLocal = `optionVar -q blendUseLocalTol`; float $pos = `optionVar -q blendPositionTol`; float $tan = `optionVar -q blendTangentTol`; int $aa = `optionVar -q blendAutoAnchor`; float $la = `optionVar -q blendLeftAnchor`; float $ls = `optionVar -q blendLeftStart`; float $le = `optionVar -q blendLeftEnd`; int $rvl = `optionVar -q blendLeftReverse`; float $ra = `optionVar -q blendRightAnchor`; float $rs = `optionVar -q blendRightStart`; float $re = `optionVar -q blendRightEnd`; int $rvr = `optionVar -q blendRightReverse`; //set controls. // checkBoxGrp -e -v1 $auto blendAutoDirectionWidget; checkBoxGrp -e -v2 $multi blendAutoDirectionWidget; checkBoxGrp -e -v1 $flipL -v2 $flipR blendFlipWidget; radioButtonGrp -e -select ($useLocal+1) blendUseLocalTolWidget; floatSliderGrp -e -v $pos blendPositionTolWidget; floatSliderGrp -e -v $tan blendTangentTolWidget; if( `isTrue "SurfaceUIExists"` ) { if( (3 == $poly) && ! `isTrue "SubdivUIExists"` ) { $poly = 2; } radioButtonGrp -e -select ($poly+1) blendOutputPolyWidget; } checkBoxGrp -e -v1 $rvl -v2 $rvr blendReverseWidget; checkBoxGrp -e -v1 $aa blendAnchorWidget; blendVisibility( $parent, $auto, $useLocal ); switch( $poly ) { 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 ); } global proc blendCallback( string $parent, int $doIt, string $goToTool ) { setParent $parent; // get Values from controls. // int $auto = `checkBoxGrp -q -v1 blendAutoDirectionWidget`; int $multi = `checkBoxGrp -q -v2 blendAutoDirectionWidget`; int $flipL = `checkBoxGrp -q -v1 blendFlipWidget`; int $flipR = `checkBoxGrp -q -v2 blendFlipWidget`; int $useLocal = `radioButtonGrp -q -select blendUseLocalTolWidget` - 1; float $pos = `floatSliderGrp -q -v blendPositionTolWidget`; float $tan = `floatSliderGrp -q -v blendTangentTolWidget`; optionVar -intValue blendAutoDirection $auto; optionVar -intValue blendMultiKnots $multi; optionVar -intValue blendFlipLeft $flipL; optionVar -intValue blendFlipRight $flipR; optionVar -intValue blendUseLocalTol $useLocal; optionVar -floatValue blendPositionTol $pos; optionVar -floatValue blendTangentTol $tan; if( `isTrue "SurfaceUIExists"` ) { int $poly = `radioButtonGrp -q -select blendOutputPolyWidget`; if( (3 == $poly) && ! `isTrue "SubdivUIExists"` ) { $poly = 4; } optionVar -intValue blendOutputPoly ($poly-1); } int $rvl = `checkBoxGrp -q -v1 blendReverseWidget`; int $rvr = `checkBoxGrp -q -v2 blendReverseWidget`; int $aa = `checkBoxGrp -q -v1 blendAnchorWidget`; nurbsToPolyCallback( $parent, 0 ); nurbsToSubdivCallback( $parent, 0 ); if( 1 == $doIt ) { performBlend( 0, $goToTool ); string $tmpCmd = "performBlend( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Fillet Blend"; } else { setToolTo $goToTool; } } global proc string performBlend( int $action, string $goToTool ) // // Description : // $action = 0 ==>do the command. // $action = 1 ==>show option box. // $action = 2 ==>drag to shelf. // $action = 3 ==>set the button to enter the tool { int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } string $cmd = ""; switch( $action ) { case 0 : // do the cmd. $cmd = `assembleCmd`; evalEcho( $cmd ); break; case 1 : // show option box. // blendOptions( $inTheTool, $goToTool ); break; case 2 : // drag to shelf the proc. // $cmd = `assembleCmd`; break; default : break; } return $cmd; }