// =========================================================================== // 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: Sept 30, 1998 // // Description: // This script defines the option box for the boolean surface menu item. // // Input Arguments: // int action // 1 - just execute the boolean operation // 2 - return the script that would do it // // Return Value: // None. // proc setOptionVars( int $opType, int $forceFactorySettings) { switch( $opType ) { case 0 : if( $forceFactorySettings || !`optionVar -exists nurbsUnionDeleteInput` ) { optionVar -intValue nurbsUnionDeleteInput 1 ; } break ; case 1 : if( $forceFactorySettings || !`optionVar -exists nurbsSubtractDeleteInput` ) { optionVar -intValue nurbsSubtractDeleteInput 1 ; } break ; case 2 : if( $forceFactorySettings || !`optionVar -exists nurbsIntersecttDeleteInput` ) { optionVar -intValue nurbsIntersectDeleteInput 1 ; } break ; } } proc string assembleCmd( int $ni, int $op ) // // Description : // To assemble boolean cmd. // { setOptionVars( $op, false ) ; int $history = `constructionHistory -q -tgl`; int $delInputs = 0; switch($op) { case 0 : $delInputs = `optionVar -q nurbsUnionDeleteInput`; break ; case 1 : $delInputs = `optionVar -q nurbsSubtractDeleteInput` ; break ; case 2 : $delInputs = `optionVar -q nurbsIntersectDeleteInput` ; break ; } string $cmd = "nurbsBooleanPreset 1 {"; $cmd = $cmd + "\"" + $history + "\", "; $cmd = $cmd + "\"" + $ni + "\", "; $cmd = $cmd + "\"" + $op + "\", "; $cmd = $cmd + "\"" + $delInputs + "\" }"; return $cmd; } proc string booleanHelp() { string $cmdHelp = "Command:- perform union or difference or intersection \n"; string $selectHelp = ("Selection: One or more NURBS surfaces followed " + "by a second set of NURBS surface."); return $cmdHelp+$selectHelp; } global proc nurbsBooleanCallback( string $parent, int $doIt, int $whichOp, string $goToTool ) { setParent $parent; string $label; // get Values from controls. // int $di = `checkBoxGrp -q -v1 nurbsBooleanDeleteInputWidget`; switch( $whichOp ) { case 0 : optionVar -intValue nurbsUnionDeleteInput $di; $label = "Union"; break ; case 1 : optionVar -intValue nurbsSubtractDeleteInput $di; $label = "Subtract"; break ; case 2 : optionVar -intValue nurbsIntersectDeleteInput $di; $label = "Intersect"; break ; } if( 1 == $doIt ) { string $list[] ; performBoolean( 0, $whichOp, $list , $goToTool ); string $tmpCmd = "performBoolean( 0, " + $whichOp + ", "; $tmpCmd += "{ \"\"}, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd $label; } else if( $doIt ) { setToolTo $goToTool; } } global proc nurbsBooleanSetup( string $parent, int $forceFactorySettings, int $whichOp, string $goToTool) { // retrieve option settings. // setOptionVars( $whichOp, $forceFactorySettings ); if( $forceFactorySettings || !`optionVar -ex booleanEuc` ) { optionVar -iv ("booleanEuc" + $whichOp) 0; } if( $forceFactorySettings || !`optionVar -ex booleanLac` ) { optionVar -iv ("booleanLac" + $whichOp) 1; } if( "" != $goToTool ) { scriptCtx -e -euc `optionVar -q ("booleanEuc"+$whichOp)` $goToTool; scriptCtx -e -lac `optionVar -q ("booleanLac"+$whichOp)` $goToTool; } setParent $parent; // query the option vars. // int $di ; switch( $whichOp ) { case 0 : $di = `optionVar -q nurbsUnionDeleteInput`; break ; case 1 : $di = `optionVar -q nurbsSubtractDeleteInput`; break ; case 2 : $di = `optionVar -q nurbsSubtractDeleteInput`; break ; } checkBoxGrp -e -v1 $di nurbsBooleanDeleteInputWidget ; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -exitUponCompletion $goToTool` -v2 `scriptCtx -q -enableRootSelection $goToTool` scriptToolExtraWidget; } } proc nurbsBooleanOptions( int $inTheTool, int $whichOp, string $goToTool ) // // Desc : // $whichOp = 0 (union ), 1 (subtract) , 2(intersect). // { // Name of the command for this option box. // string $commandName = "nurbsBoolean"; // 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 1 -label1 (uiRes("m_performBoolean.kDeleteInputs")) nurbsBooleanDeleteInputWidget; checkBoxGrp -ncb 2 -label (uiRes("m_performBoolean.kToolBehavior")) -label1 (uiRes("m_performBoolean.kExit")) -v1 on -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performBoolean.kHierarchy")) -v2 on -on2 ("scriptCtx -e -ers true " + $goToTool) -of2 ("scriptCtx -e -ers false " + $goToTool) scriptToolExtraWidget; setParent ..; // 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(); string $opLabel ; string $opLabelTool; string $title; switch( $whichOp ) { case 0 : $opLabel = (uiRes("m_performBoolean.kUnion")); $opLabelTool = (uiRes("m_performBoolean.kUnionTool")); $title = (uiRes("m_performBoolean.kUnionTitle")); break ; case 1 : $opLabel = (uiRes("m_performBoolean.kDifference")); $opLabelTool = (uiRes("m_performBoolean.kDifferenceTool")); $title = (uiRes("m_performBoolean.kDifferenceTitle")); break ; case 2 : $opLabel = (uiRes("m_performBoolean.kIntersection")); $opLabelTool = (uiRes("m_performBoolean.kIntersectionTool")); $title = (uiRes("m_performBoolean.kIntersectionTitle")); break ; } if( $inTheTool ) { button -edit -label $opLabelTool -command ($callback + " " + $parent + " " + 3 + " " + $whichOp + " " + $goToTool ) $applyBtn; } else { button -edit -label $opLabel -command ($callback + " " + $parent + " " + 1 + " " + $whichOp + " \"" + $goToTool + "\"" ) $applyBtn; } // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " " + $whichOp + " \"" + $goToTool + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1 + " " + $whichOp + " \"" + $goToTool + "\"") $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle($title); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "NurbsBoolean" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " " + 0 + " " + $whichOp + " \"" + $goToTool + "\"" ); // Step 10: Show the option box. // ============================= // showOptionBox(); } global proc string performBoolean( int $action, int $opType, string $list1[], string $goToTool ) // // Description : // $action = 0 ==> do the nurbs union|subtract|intersect command. // $action = 1 ==>show option box. // $action = 2 ==>drag to shelf. { string $cmd = ""; int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } int $ni = size($list1) ; // find only valid items. // switch( $action ) { case 0 : $cmd = `assembleCmd $ni $opType`; eval $cmd; break; case 1 : nurbsBooleanOptions( $inTheTool, $opType, $goToTool ); break ; case 2 : $cmd = `assembleCmd $ni $opType`; break; default : break; } return $cmd; }