// =========================================================================== // 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 14, 1997 // // Description: // This script is defines the option box for the detach menu item. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { // "-rpo/-replaceOriginal" flag for detach commands. if ($forceFactorySettings || !`optionVar -exists detachKeepOriginal`) { optionVar -intValue detachKeepOriginal 0; } } // // Procedure Name: // detachSetup // // Description: // Update the state of the option box UI to reflect the 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 detachSetup(string $parent, int $forceFactorySettings, string $goToTool) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; int $keepOriginal = `optionVar -query detachKeepOriginal`; checkBoxGrp -edit -value1 $keepOriginal keepOriginalCheckBox; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc detachCurveSetup(string $parent, int $forceFactorySettings, string $goToTool) { detachSetup( $parent, $forceFactorySettings, $goToTool ); detachCurveToolSetup( $forceFactorySettings, $goToTool ); } global proc detachSurfaceSetup(string $parent, int $forceFactorySettings, string $goToTool) { detachSetup( $parent, $forceFactorySettings, $goToTool ); detachSurfaceToolSetup( $forceFactorySettings, $goToTool ); } // // Procedure Name: // detachCallback // // 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 detachCallback(string $parent, int $doIt, string $goToTool) { setParent $parent; int $keep = `checkBoxGrp -query -value1 keepOriginalCheckBox`; optionVar -intValue detachKeepOriginal $keep; if( 1 == $doIt ) { performDetach( 0, "", $goToTool ); string $tmpCmd = "performDetach( 0, \"\", \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Detach"; } else if( $doIt ) { setToolTo $goToTool; } } global proc detachCurveCallback(string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv detachCurveEuc `scriptCtx -q -euc $goToTool`; optionVar -iv detachCurveLac `scriptCtx -q -lac $goToTool`; } detachCallback( $parent, $doIt, $goToTool ); } global proc detachSurfaceCallback(string $parent, int $doIt, string $goToTool) { if( "" != $goToTool ) { optionVar -iv detachSurfaceEuc `scriptCtx -q -euc $goToTool`; optionVar -iv detachSurfaceLac `scriptCtx -q -lac $goToTool`; } detachCallback( $parent, $doIt, $goToTool ); } // // Procedure Name: // detachOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // string $objectType: Is this detach Curves or detach Surfaces? // None. // // Return Value: // None. // proc detachOptions(string $objectType, int $inTheTool, string $goToTool) { // Name of the command for this option box. // string $commandName = "detach"; // Build the option box actions. // string $callback = ($commandName + $objectType + "Callback"); string $setup = ($commandName + $objectType + "Setup"); // Step 1: Get the option box. // ============================ global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolDetach" + $objectType; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "detach" + $objectType + "ToolScript 3"; string $layout = getOptionBox(); setParent $layout; // Step 2: 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+$objectType); // 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_performDetach.kKeepOriginal")) keepOriginalCheckBox; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performDetach.kToolBehavior")) -label1 (uiRes("m_performDetach.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performDetach.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_performDetach.kDetachTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"" ) $applyBtn; } else { button -edit -label (uiRes("m_performDetach.kDetach")) -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 ) { if( $objectType == "Curve" ) { setOptionBoxTitle (uiRes("m_performDetach.kDetachCurveToolOption")); } else { setOptionBoxTitle (uiRes("m_performDetach.kDetachSurfaceToolOption")); } } else { if( $objectType == "Curve" ) { setOptionBoxTitle (uiRes("m_performDetach.kDetachCurveOptions")); } else { setOptionBoxTitle (uiRes("m_performDetach.kDetachSurfaceOptions")); } } // Step 8: Customize the 'Help' menu item text. // ============================================ // if ($objectType == "Curve") { setOptionBoxHelpTag( "DetachCurves" ); } else { setOptionBoxHelpTag( "DetachSurfaces" ); } // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // detachHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string detachHelp() { return " Command: Detach - detach a curve on surface\n" + "Selection: curve point, curve on surface point, surface isoparm"; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd = "performDetachPreset"; setOptionVars(false); int $rpo = !`optionVar -query detachKeepOriginal`; int $history = `constructionHistory -q -tgl`; $cmd = ( $cmd + " " + $history + " " + $rpo); return $cmd; } // // Procedure Name: // performDetach // // Description: // Perform the detach 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 detach command with the current // option box values. // // Return Value: // None. // global proc string performDetach(int $action, string $objectType, string $goToTool ) // For $action: // 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: setOptionVars(false); $cmd = `assembleCmd`; eval($cmd); break; case 1: detachOptions( $objectType, $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }