// =========================================================================== // 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: 15 April 1997 // // Description: // Initialize the option values for fillet curve menu item. // // Input Arguments: // int action // 0 - just execute the fillet curve operation // 1 - show the option box dialog // 2 - drag to shelf // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { // Trim (on-1 or off-0). // if ($forceFactorySettings || !`optionVar -exists filletCurveTrim`) { optionVar -intValue filletCurveTrim 0; } // Join (on-1 or off-0 to be used if trim is on). // if ($forceFactorySettings || !`optionVar -exists filletCurveJoin`) { optionVar -intValue filletCurveJoin 0; } // Circular style (circular-1 freeform-0). // if ($forceFactorySettings || !`optionVar -exists filletCurveCircularStyle`) { optionVar -intValue filletCurveCircularStyle 1; } // Radius (used if circular style is 1). // if ($forceFactorySettings || !`optionVar -exists filletCurveRadius`) { optionVar -floatValue filletCurveRadius 1.0; } // Freeform blend type (blend-1 tangent-0). // if ($forceFactorySettings || !`optionVar -exists filletCurveFreeformBlendType`) { optionVar -intValue filletCurveFreeformBlendType 1; } // Blend control (on-1 or off-0 used for depth and bias). // if ($forceFactorySettings || !`optionVar -exists filletCurveBlendControl`) { optionVar -intValue filletCurveBlendControl 0; } // Depth (used if blend control is 1). // if ($forceFactorySettings || !`optionVar -exists filletCurveDepth`) { optionVar -floatValue filletCurveDepth 0.5; } // Bias (used if blend control is 1). // if ($forceFactorySettings || !`optionVar -exists filletCurveBias`) { optionVar -floatValue filletCurveBias 0.0; } // keep original (for in place operations is on-1 or off-0 used if // trim is 1). // if ($forceFactorySettings || !`optionVar -exists filletCurveKeepOriginal`) { optionVar -intValue filletCurveKeepOriginal 0; } } // // Procedure Name: // filletCurveSetup // // Description: // Update the state of the option box UI to reflect the filletCurve // 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 filletCurveSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars($forceFactorySettings); filletCurveToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls. // Trim. // int $doTrim = `optionVar -query filletCurveTrim`; checkBoxGrp -edit -value1 $doTrim filletCurveTrimBox; // Join. // checkBoxGrp -edit -value1 `optionVar -query filletCurveJoin` -enable $doTrim filletCurveJoinBox; // Circular style (if freeform style then the 2nd button should be // selected). // int $whichStyle = `optionVar -query filletCurveCircularStyle`; if ( $whichStyle == 0 ) $whichStyle = 2; radioButtonGrp -edit -select $whichStyle filletCurveTypeBtn; if ( $whichStyle == 2 ) { // freeform floatSliderGrp -e -enable 0 filletCurveRadiusSlider; radioButtonGrp -e -enable 1 filletCurveFreeFormTypeBtn; } else if ( $whichStyle == 1 ) { // circular floatSliderGrp -e -enable 1 filletCurveRadiusSlider; radioButtonGrp -e -enable 0 filletCurveFreeFormTypeBtn; } // Radius // floatSliderGrp -edit -value `optionVar -query filletCurveRadius` filletCurveRadiusSlider; // Freeform blend type (if tangent type then the 2nd button should be // selected). // int $whichType = `optionVar -query filletCurveFreeformBlendType` + 1; radioButtonGrp -edit -select $whichType filletCurveFreeFormTypeBtn; // Blend control // int $isBlendControl = `optionVar -query filletCurveBlendControl`; checkBoxGrp -edit -value1 $isBlendControl filletCurveBlendControlBox; if ( $isBlendControl == 0 ) { floatSliderGrp -e -enable 0 filletCurveDepthSlider; floatSliderGrp -e -enable 0 filletCurveBiasSlider; } else { floatSliderGrp -e -enable 1 filletCurveDepthSlider; floatSliderGrp -e -enable 1 filletCurveBiasSlider; } // Depth // floatSliderGrp -edit -value `optionVar -query filletCurveDepth` filletCurveDepthSlider; // Bias // floatSliderGrp -edit -value `optionVar -query filletCurveBias` filletCurveBiasSlider; // Keep original. // checkBoxGrp -edit -value2 `optionVar -query filletCurveKeepOriginal` -enable $doTrim filletCurveJoinBox; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } // // Procedure Name: // filletCurveCallback // // 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 filletCurveCallback(string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv filletCurveEuc `scriptCtx -q -euc $goToTool`; optionVar -iv filletCurveLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // Trim. // optionVar -intValue filletCurveTrim `checkBoxGrp -query -value1 filletCurveTrimBox`; // Join. // optionVar -intValue filletCurveJoin `checkBoxGrp -query -value1 filletCurveJoinBox`; // Circular style (if freeform the query will give 2 as the selected // button but we need the value as 0 for freeform and 1 for circular). // int $whichStyle = `radioButtonGrp -query -select filletCurveTypeBtn`; if ( $whichStyle == 2 ) $whichStyle = 0; optionVar -intValue filletCurveCircularStyle $whichStyle; if ( $whichStyle == 0 ) { // freeform fillet style - get blend type (if tangent the query will // give 2 as the selected button but we need the value as 0 for // tangent and 1 for blend). int $whichType = `radioButtonGrp -query -select filletCurveFreeFormTypeBtn` - 1; optionVar -intValue filletCurveFreeformBlendType $whichType; } else if ( $whichStyle == 1 ) { // circular fillet style - get radius optionVar -floatValue filletCurveRadius `floatSliderGrp -query -value filletCurveRadiusSlider`; } int $isBlendControl = `checkBoxGrp -query -value1 filletCurveBlendControlBox`; optionVar -intValue filletCurveBlendControl $isBlendControl; if ( $isBlendControl == 1 ) { // depth and bias optionVar -floatValue filletCurveDepth `floatSliderGrp -query -value filletCurveDepthSlider`; optionVar -floatValue filletCurveBias `floatSliderGrp -query -value filletCurveBiasSlider`; } // Keep original. // optionVar -intValue filletCurveKeepOriginal `checkBoxGrp -query -value2 filletCurveJoinBox`; if (1 == $doIt) { performFilletCurve( 0, $goToTool ); string $tmpCmd = "performFilletCurve( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Curve Fillet"; } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // createFilletCurveUI // // Description: // Fill the contents of the option box for filletCurve command. // // Input Arguments: // The name of the parent layout. // // Return Value: // None. // proc createFilletCurveUI(string $parent, int $inTheTool, string $goToTool) { setParent $parent; // the trim/join options // checkBoxGrp -label "" -numberOfCheckBoxes 1 -label1 (uiRes("m_performFilletCurve.kTrim")) -onCommand ("checkBoxGrp -e -enable true filletCurveJoinBox;") -offCommand ("checkBoxGrp -e -enable false filletCurveJoinBox;") filletCurveTrimBox; // the first time the option box is opened this checkbox // should be dimmed because trim is off by default // checkBoxGrp -enable false -label "" -numberOfCheckBoxes 2 -label1 (uiRes("m_performFilletCurve.kJoin")) -label2 (uiRes("m_performFilletCurve.kKeepOriginal")) filletCurveJoinBox; separator; radioButtonGrp -label (uiRes("m_performFilletCurve.kConstruction")) -numberOfRadioButtons 2 -label1 (uiRes("m_performFilletCurve.kCircular")) -da1 1 -label2 (uiRes("m_performFilletCurve.kFreeform")) -da2 0 -onCommand1 ("floatSliderGrp -e -enable 1 filletCurveRadiusSlider; radioButtonGrp -e -enable 0 filletCurveFreeFormTypeBtn;") -onCommand2 ("floatSliderGrp -e -enable 0 filletCurveRadiusSlider; radioButtonGrp -e -enable 1 filletCurveFreeFormTypeBtn;") filletCurveTypeBtn; floatSliderGrp -label (uiRes("m_performFilletCurve.kRadius")) -field true -min -100.0 -max 100.0 filletCurveRadiusSlider; radioButtonGrp -label (uiRes("m_performFilletCurve.kFreeformType")) -numberOfRadioButtons 2 -label1 (uiRes("m_performFilletCurve.kTangent")) -da1 0 -label2 (uiRes("m_performFilletCurve.kBlend")) -da2 1 filletCurveFreeFormTypeBtn; checkBoxGrp -label "" -numberOfCheckBoxes 1 -label1 (uiRes("m_performFilletCurve.kBlendControl")) -onCommand ("floatSliderGrp -e -enable 1 filletCurveDepthSlider; floatSliderGrp -e -enable 1 filletCurveBiasSlider;") -offCommand ("floatSliderGrp -e -enable 0 filletCurveDepthSlider; floatSliderGrp -e -enable 0 filletCurveBiasSlider;") filletCurveBlendControlBox; floatSliderGrp -label (uiRes("m_performFilletCurve.kDepth")) -field true filletCurveDepthSlider; floatSliderGrp -label (uiRes("m_performFilletCurve.kBias")) -field true -min -1.0 -max 1.0 filletCurveBiasSlider; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performFilletCurve.kToolBehavior")) -label1 (uiRes("m_performFilletCurve.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performFilletCurve.kAutoCompletion")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } } // // Procedure Name: // filletCurveOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc filletCurveOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "filletCurve"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolFilletCurve"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "filletCurveToolScript 3"; // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // Pass the command name to the option box. // // Any default option box behavior based on the command name is set // up with this call. // setOptionBoxCommandName($commandName); // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // Turn on the wait cursor. // waitCursor -state 1; // RECOMMENDATION: Place the UI in a scroll layout. If the // option box window is ever resized such that it's entire // contents is not visible then the scroll bars provided by the // scroll layout will allow the user to access the hidden UI. // tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; // Create the UI for the tab that is initially visible. // createFilletCurveUI($parent, $inTheTool, $goToTool); // Turn off the wait cursor. // waitCursor -state 0; // Deactivate the default UI template. // setUITemplate -popTemplate; // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'FilletCurve' button. // string $applyBtn = getOptionBoxApplyBtn(); if( $inTheTool ) { button -edit -label (uiRes("m_performFilletCurve.kFilletTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performFilletCurve.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; // Set the option box title. // if( $inTheTool ) { setOptionBoxTitle (uiRes("m_performFilletCurve.kFilletCurveToolOptions")); } else { setOptionBoxTitle (uiRes("m_performFilletCurve.kFilletCurveOptions")); } // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CurveFillet" ); // Set the current values of the option box. // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Show the option box. // showOptionBox(); } // // Procedure Name: // filletCurveHelp // // Description: // Returns a short description about the filletCurve command. // // Input Arguments: // None. // // Return Value: // string. // proc string filletCurveHelp() { return " Command: FilletCurve - create a fillet curve between two other curves.\n" + "Selection: two curves or a parameter point on two curves."; } // // Procedure Name: // assembleCmd // // Description: // Construct the filletCurve command that will apply the option box // values. // // Input Arguments: // None. // // Return Value: // The filletCurve command string. // proc string assembleCmd() { setOptionVars(false); // get the global history flag value int $doHistory = `constructionHistory -q -tgl`; // trim related values int $replaceOriginal = !`optionVar -q filletCurveKeepOriginal`; int $trim = `optionVar -query filletCurveTrim`; int $join = `optionVar -query filletCurveJoin`; // circular style value int $circular = `optionVar -query filletCurveCircularStyle`; float $radius = `optionVar -query filletCurveRadius`; // the freeform style related value int $freeformBlendType = `optionVar -query filletCurveFreeformBlendType`; // blend control related values int $blendControl = `optionVar -query filletCurveBlendControl`; float $depth = `optionVar -query filletCurveDepth`; float $bias = `optionVar -query filletCurveBias`; // set up string for preset function call string $cmd = "filletCurvePreset"; $cmd = $cmd + "(" ; $cmd = $cmd + $doHistory; $cmd = $cmd + ","; $cmd = $cmd + $replaceOriginal; $cmd = $cmd + ","; $cmd = $cmd + $trim; $cmd = $cmd + ","; $cmd = $cmd + $join; $cmd = $cmd + ","; $cmd = $cmd + $circular; $cmd = $cmd + ","; $cmd = $cmd + $radius; $cmd = $cmd + ","; $cmd = $cmd + $freeformBlendType; $cmd = $cmd + ","; $cmd = $cmd + $blendControl; $cmd = $cmd + ","; $cmd = $cmd + $depth; $cmd = $cmd + ","; $cmd = $cmd + $bias; $cmd = $cmd + ")"; return $cmd; } // // Procedure Name: // performFilletCurve // // Description: // Perform the filletCurve 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 filletCurve command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command to drag to shelf. // // Return Value: // The filletCurve command string. // global proc string performFilletCurve(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: filletCurveOptions( $inTheTool, $goToTool ); break; case 2: setOptionVars(false); $cmd = `assembleCmd`; break; } return $cmd; }