// =========================================================================== // 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 24, 1997 // // // Description: // This script is defines the option box for the freeFormFillet surface menu item. // // Input Arguments: // int action // 0 - show the option box dialog // 1 - just execute the extrude operation // 2.- drag current settings to chest // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { freeFormFilletSetOptionVars( $forceFactorySettings ); } global proc freeFormFilletVisibility( string $parent, int $useGlobalTol ) { if( $useGlobalTol < 0 ) { $useGlobalTol = `radioButtonGrp -q -select toleranceRadioButtonGrp`; } if( $useGlobalTol == 1 ) { tabLayout -e -vis false localToleranceTabLayout; } else { tabLayout -e -vis true localToleranceTabLayout; } } global proc freeFormFilletSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // retrieve option settings. // setOptionVars($forceFactorySettings); freeFilletToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // query all the option vars. // float $depth = `optionVar -q freeFormFilletDepth` ; floatSliderGrp -edit -value $depth ffsDepthControlSlider ; float $bias = `optionVar -q freeFormFilletBias` ; floatSliderGrp -edit -value $bias ffsBiasControlSlider ; // Nurbs or poly ? // int $polygons = `optionVar -q freeFormFilletOutputPolygons` ; if( (3 == $polygons) && ! `isTrue "SubdivUIExists"` ) { $polygons = 2; } radioButtonGrp -edit -select ($polygons+1) outputPolyRadioButtonGrp; // polygon controls. // switch( $polygons ) { 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; } nurbsToPolySetup( $parent, $forceFactorySettings ); nurbsToSubdivSetup( $parent, $forceFactorySettings ); // Global Vs Local ? // int $useGlobalTol = `optionVar -query freeFormFilletUseGlobalTolerance`; float $localPosTol = `optionVar -query freeFormFilletLocalPositionalTolerance`; float $localTanTol = `optionVar -query freeFormFilletLocalTangentTolerance`; int $selButton = 2 ; if( $useGlobalTol == 1 ) $selButton = 1 ; radioButtonGrp -edit -select $selButton toleranceRadioButtonGrp; floatSliderGrp -edit -value $localPosTol localPosTolFloatFieldGrp; floatSliderGrp -edit -value $localTanTol localTanTolFloatFieldGrp; freeFormFilletVisibility $parent $useGlobalTol; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc freeFormFilletCallback( string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv freeFilletEuc `scriptCtx -q -euc $goToTool`; optionVar -iv freeFilletLac `scriptCtx -q -lac $goToTool`; } setParent $parent ; // get and set Values from controls. // int $polygons = `radioButtonGrp -q -select outputPolyRadioButtonGrp`; if( (3 == $polygons) && ! `isTrue "SubdivUIExists"` ) { $polygons = 4; } optionVar -intValue freeFormFilletOutputPolygons ($polygons-1); // get and set values from controls. // float $depthValue = `floatSliderGrp -q -value ffsDepthControlSlider` ; float $biasValue = `floatSliderGrp -q -value ffsBiasControlSlider` ; optionVar -floatValue freeFormFilletDepth $depthValue ; optionVar -floatValue freeFormFilletBias $biasValue ; // global Vs local Tolerance. // int $useGlobalTol = 0 ; int $tolButton = `radioButtonGrp -q -select toleranceRadioButtonGrp`; if( $tolButton == 1 ) $useGlobalTol = 1 ; float $localPostol = `floatSliderGrp -q -value localPosTolFloatFieldGrp`; float $localTantol = `floatSliderGrp -q -value localTanTolFloatFieldGrp`; optionVar -intValue freeFormFilletUseGlobalTolerance $useGlobalTol; optionVar -floatValue freeFormFilletLocalPositionalTolerance $localPostol; optionVar -floatValue freeFormFilletLocalTangentTolerance $localTantol; nurbsToPolyCallback( $parent, 0 ); nurbsToSubdivCallback( $parent, 0 ); if( 1 == $doIt ) { performFreeFormFillet( 0, $goToTool ); string $tmpCmd = "performFreeFormFillet( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Freeform Fillet"; } else if( $doIt ) { setToolTo $goToTool; } } proc freeFormFilletOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "freeFormFillet"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolFreeFillet"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "freeFilletToolScript 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`; floatSliderGrp -field true -min -1.0 -max 1.0 -label (uiRes("m_performFreeFormFillet.kBias")) ffsBiasControlSlider ; floatSliderGrp -field true -min 0.0 -max 1.0 -label (uiRes("m_performFreeFormFillet.kDepth")) ffsDepthControlSlider ; separator; tabLayout -tabsVisible false toleranceTabLayout; columnLayout toleranceGroups; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performFreeFormFillet.kUseTolerance")) -label1 (uiRes("m_performFreeFormFillet.kGlobal")) -label2 (uiRes("m_performFreeFormFillet.kLocal")) toleranceRadioButtonGrp; tabLayout -tabsVisible false localToleranceTabLayout; columnLayout localToleranceSlider; floatSliderGrp -label (uiRes("m_performFreeFormFillet.kPositionalTolerance")) -min 0.0001 -max 0.1 -fmn 0.00001 -fmx 10000.0 localPosTolFloatFieldGrp; floatSliderGrp -label (uiRes("m_performFreeFormFillet.kCTangentTolerance")) -min 0.0001 -max 0.1 -fmn 0.00001 -fmx 10000.0 localTanTolFloatFieldGrp; setParent ..; setParent ..; setParent ..; setParent ..; radioButtonGrp -edit -cc1 ("freeFormFilletVisibility " + $parent + " 1") -cc2 ("freeFormFilletVisibility " + $parent + " 0") toleranceRadioButtonGrp; separator; string $outputGeometry = (uiRes("m_performFreeFormFillet.kOutputGeometry")); string $nurbs = (uiRes("m_performFreeFormFillet.kNurbs")); string $polygons = (uiRes("m_performFreeFormFillet.kPolygons")); string $bezier = (uiRes("m_performFreeFormFillet.kBezier")); if( `isTrue "SubdivUIExists"` ) { radioButtonGrp -nrb 4 -label $outputGeometry -label1 $nurbs -label2 $polygons -label3 (uiRes("m_performFreeFormFillet.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_performFreeFormFillet.kToolBehavior")) -label1 (uiRes("m_performFreeFormFillet.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performFreeFormFillet.kAuto")) -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_performFreeFormFillet.kFilletTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performFreeFormFillet.kFillet")) -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_performFreeFormFillet.kFilletToolTitle")); } else { setOptionBoxTitle (uiRes("m_performFreeFormFillet.kFilletTitle")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "FreeformFillet" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string freeFormFilletHelp() // // Description : A short description of the freeFormFilletCmd. // { string $helpStr = "Command: freeFormFillet creates a surface fillet given two surface edges|isoparam|curve on surface" ; return $helpStr ; } proc string assembleCmd() // // Description : // To assemble freeFormFillet proc. // { global float $positionalTolerance ; global float $tangentialTolerance ; setOptionVars(false); string $cmd = "freeFormFilletPreset" ; int $history = `constructionHistory -q -tgl`; int $useGlobalTol = `optionVar -q freeFormFilletUseGlobalTolerance` ; float $posTol ; float $tanTol ; if( $useGlobalTol == 1 ) { $posTol = `optionVar -q positionalTolerance` ; $tanTol = `optionVar -q tangentialTolerance` ; } else { $posTol = `optionVar -q freeFormFilletLocalPositionalTolerance` ; $tanTol = `optionVar -q freeFormFilletLocalTangentTolerance` ; } //int $curveRangePartial = `optionVar -q freeFormFilletCurveRangePartial` ; int $polygons = `optionVar -q freeFormFilletOutputPolygons` ; float $depth = `optionVar -q freeFormFilletDepth`; float $bias = `optionVar -q freeFormFilletBias`; $cmd = $cmd + "(" ; $cmd = $cmd + $history ; $cmd = $cmd + "," ; //$cmd = $cmd + $curveRangePartial ; //$cmd = $cmd + "," ; $cmd = $cmd + $polygons ; $cmd = $cmd + "," ; $cmd = $cmd + $depth ; $cmd = $cmd + "," ; $cmd = $cmd + $bias ; $cmd = $cmd + "," ; $cmd = $cmd + $posTol ; $cmd = $cmd + "," ; $cmd = $cmd + $tanTol ; $cmd = $cmd + ")" ; return $cmd ; } global proc string performFreeFormFillet( int $action, string $goToTool ) // // Description : // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // 3 - Show the tool option box dialog. { int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } string $cmd = "" ; switch( $action ) { case 0 : $cmd = `assembleCmd` ; eval $cmd ; break ; case 1 : freeFormFilletOptions( $inTheTool, $goToTool ); break ; case 2 : default: $cmd = `assembleCmd` ; break ; } return $cmd ; }