// =========================================================================== // 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: April 29, 1997 // // Description: // This script is defines the option box for the circular fillet // surface menu item. // // Input Arguments: // int action // 0 - show the option box dialog // 1 - just execute the fillet operation. // // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { circularFilletSetOptionVars( $forceFactorySettings ); } global proc circularFilletVisibility( 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 circularFilletSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // retrieve option settings. // setOptionVars($forceFactorySettings); circFilletToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // query all the option vars. // int $genCoS = `optionVar -q circularFilletGenerateCoS` ; int $cosGen ; if( $genCoS == 1 ) $cosGen = 1 ; else $cosGen = 0 ; checkBoxGrp -edit -v1 $cosGen circularFilletCoSBox ; // reverse primary. // int $rev = `optionVar -q circularFilletReversePrimary` ; int $revP ; if( $rev == 0 ) $revP = 0 ; else $revP = 1 ; checkBoxGrp -edit -v1 $revP circularFilletRevPBox ; // reverse secondary. // $rev = `optionVar -q circularFilletReverseSecondary` ; int $revS ; if( $rev == 0 ) $revS = 0 ; else $revS = 1 ; checkBoxGrp -edit -v1 $revS circularFilletRevSBox ; // get and set controls. // float $pr = `optionVar -q circularFilletRadius` ; floatSliderGrp -e -v $pr circularFilletRadiusField ; floatSliderGrp -e -min -1.0 -max 1.0 -fmn -10000.0 -fmx 10000.0 circularFilletRadiusField ; // polygon controls. // //int $outputPolys = `optionVar -q circularFilletOutputPolygons`; //radioButtonGrp -edit -select ($outputPolys+1) outputPolyRadioButtonGrp; //if( $outputPolys ) { // tabLayout -e -vis true polyOptions; //} else { // tabLayout -e -vis false polyOptions; //} //nurbsToPolySetup( $parent, $forceFactorySettings ); // Query the optionVar's and set the values into the controls // int $useGlobalTol = `optionVar -query circularFilletUseGlobalTolerance`; float $localPosTol = `optionVar -query circularFilletLocalPositionalTolerance`; float $localTanTol = `optionVar -query circularFilletLocalTangentTolerance`; int $selButton ; if( $useGlobalTol == 1 ) $selButton = 1 ; else $selButton = 2 ; radioButtonGrp -edit -select $selButton toleranceRadioButtonGrp; floatSliderGrp -edit -value $localPosTol localPosTolFloatFieldGrp; floatSliderGrp -edit -value $localTanTol localTanTolFloatFieldGrp; circularFilletVisibility $parent $useGlobalTol; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc circularFilletCallback( string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv circFilletEuc `scriptCtx -q -euc $goToTool`; optionVar -iv circFilletLac `scriptCtx -q -lac $goToTool`; } setParent $parent ; // get Values from controls. // int $genCoS ; $genCoS = `checkBoxGrp -q -v1 circularFilletCoSBox` ; optionVar -intValue circularFilletGenerateCoS $genCoS ; int $rev ; $rev = `checkBoxGrp -q -v1 circularFilletRevPBox` ; optionVar -intValue circularFilletReversePrimary $rev ; $rev = `checkBoxGrp -q -v1 circularFilletRevSBox` ; optionVar -intValue circularFilletReverseSecondary $rev ; float $pr = `floatSliderGrp -q -v circularFilletRadiusField` ; optionVar -floatValue circularFilletRadius $pr ; //int $outputPolys = `radioButtonGrp -q -select outputPolyRadioButtonGrp` -1; //optionVar -intValue circularFilletOutputPolygons $outputPolys; 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 circularFilletUseGlobalTolerance $useGlobalTol; optionVar -floatValue circularFilletLocalPositionalTolerance $localPostol; optionVar -floatValue circularFilletLocalTangentTolerance $localTantol; //nurbsToPolyCallback( $parent, 0 ); if( 1 == $doIt ) { performCircularFillet(0,$goToTool); string $tmpCmd = "performCircularFillet(0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Circular Fillet"; } else if( $doIt ) { setToolTo $goToTool; } } proc string assembleCmd() // // Description : // To assemble circularFillet proc. // { // global Tolerances. // global float $positionalTolerance ; global float $tangentialTolerance ; setOptionVars(false); string $cmd = "circularFilletPreset" ; $cmd = $cmd + "(" ; int $history = `constructionHistory -q -tgl`; $cmd = $cmd + $history ; $cmd = $cmd + "," ; //int $poly = `optionVar -q circularFilletOutputPolygons` ; int $poly = 0 ; $cmd = $cmd + $poly ; $cmd = $cmd + "," ; float $pr = `optionVar -q circularFilletRadius` ; $cmd = $cmd + $pr ; $cmd = $cmd + "," ; int $revPrim = `optionVar -q circularFilletReversePrimary`; $cmd = $cmd + $revPrim ; $cmd = $cmd + "," ; int $revSec = `optionVar -q circularFilletReverseSecondary`; $cmd = $cmd + $revSec ; $cmd = $cmd + "," ; //float $sr = `optionVar -q circularFilletSecondaryRadius` ; //$cmd = $cmd + $pr ; //$cmd = $cmd + "," ; int $useGlobalTol = `optionVar -q circularFilletUseGlobalTolerance` ; float $posTol = 0.1 ; float $tanTol ; if( $useGlobalTol == 1 ) { $posTol = `optionVar -q positionalTolerance` ; $tanTol = `optionVar -q tangentialTolerance` ; } else { $posTol = `optionVar -q circularFilletLocalPositionalTolerance` ; $tanTol = `optionVar -q circularFilletLocalTangentTolerance` ; } $cmd = $cmd + $posTol ; $cmd = $cmd + "," ; $cmd = $cmd + $tanTol ; $cmd = $cmd + "," ; int $genCos = `optionVar -q circularFilletGenerateCoS` ; $cmd = $cmd + $genCos ; $cmd = $cmd + ")" ; return $cmd ; } proc circularFilletOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "circularFillet"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolCircFillet"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "circFilletToolScript 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`; // Generate CoS. // checkBoxGrp -label "" -numberOfCheckBoxes 1 -label1 (uiRes("m_performCircularFillet.kCreateCurve")) circularFilletCoSBox; // reverse primary surface. // checkBoxGrp -label "" -numberOfCheckBoxes 1 -label1 (uiRes("m_performCircularFillet.kReversePrimarySurface")) circularFilletRevPBox; // reverse secondary surface. // checkBoxGrp -label "" -numberOfCheckBoxes 1 -label1 (uiRes("m_performCircularFillet.kReverseSecondary")) circularFilletRevSBox; // float slider Group for primary radius. // floatSliderGrp -label (uiRes("m_performCircularFillet.kRadius")) -min 0.0 -max 1.0 -fmn 0.0 -fmx 10000.0 circularFilletRadiusField ; separator; tabLayout -tabsVisible false toleranceTabLayout; columnLayout toleranceGroups; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performCircularFillet.kUseTolerance")) -label1 (uiRes("m_performCircularFillet.kGlobal")) -label2 (uiRes("m_performCircularFillet.kLocal")) toleranceRadioButtonGrp; tabLayout -tabsVisible false localToleranceTabLayout; columnLayout localToleranceSlider; floatSliderGrp -label (uiRes("m_performCircularFillet.kPositionalTolerance")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 10000.0 localPosTolFloatFieldGrp; floatSliderGrp -label (uiRes("m_performCircularFillet.kTangentTolerance")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 10000.0 localTanTolFloatFieldGrp; setParent ..; setParent ..; setParent ..; setParent ..; radioButtonGrp -edit -cc1 ("circularFilletVisibility " + $parent + " 1") -cc2 ("circularFilletVisibility " + $parent + " 0") toleranceRadioButtonGrp; //separator; // output Geometry // //radioButtonGrp -numberOfRadioButtons 2 // -label "Output Geometry" // -label1 "Nurbs" // -label2 "Polygons" // -cc1 "tabLayout -e -vis false polyOptions" // -cc2 "tabLayout -e -vis true polyOptions" // outputPolyRadioButtonGrp; //tabLayout -tabsVisible false polyOptions; // string $par = `columnLayout polyOptionsOK`; // nurbsToPolyAddOptions $par; //setParent ..; // setParent ..; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performCircularFillet.kToolBehavior")) -label1 (uiRes("m_performCircularFillet.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performCircularFillet.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_performCircularFillet.kFilletTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performCircularFillet.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_performCircularFillet.kFilletToolTitle")); } else { setOptionBoxTitle (uiRes("m_performCircularFillet.kFilletTitle")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CircularFillet" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string circularFilletHelp() { string $help = "Command: circularFillet>- create a circular " + "fillet surface \nSelection: Select two NURBS surfaces " + "two surface isoparms, or two surface points"; return $help; } global proc string performCircularFillet( 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 : circularFilletOptions( $inTheTool, $goToTool) ; break ; case 2 : default: $cmd = `assembleCmd` ; break ; } return $cmd ; }