// =========================================================================== // 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: 11 April 1997 // // Description: // Initialize the option values for duplicate curve menu item. // // Input Arguments: // int action // 0 - just execute the duplicate curve operation // 1 - show the option box dialog // 2 - drag to shelf // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists duplicateCurveLocal`) { optionVar -intValue duplicateCurveLocal 0; } if ($forceFactorySettings || !`optionVar -exists duplicateCurveIsoparms`) { optionVar -intValue duplicateCurveIsoparms 2; } } // // Procedure Name: // duplicateCurveSetup // // Description: // Update the state of the option box UI to reflect the duplicate curve // 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 duplicateCurveSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars($forceFactorySettings); duplicateCurveToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls. int $local = `optionVar -query duplicateCurveLocal`; checkBoxGrp -edit -v1 $local localButton; int $iso = `optionVar -query duplicateCurveIsoparms`; radioButtonGrp -edit -select ($iso+1) isoparmsButton; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -exitUponCompletion $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } // // Procedure Name: // duplicateCurveCallback // // 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 duplicateCurveCallback( string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv duplicateCurveEuc `scriptCtx -q -euc $goToTool`; optionVar -iv duplicateCurveLac `scriptCtx -q -lac $goToTool`; } setParent $parent; // Set the optionVar's from the control values, and then // perform the command. int $local = `checkBoxGrp -query -v1 localButton`; optionVar -intValue duplicateCurveLocal $local; int $iso = `radioButtonGrp -query -select isoparmsButton`; optionVar -intValue duplicateCurveIsoparms ($iso-1); if( 1 == $doIt ) { performDuplicateCurve( 0, $goToTool ); string $tmpCmd = "performDuplicateCurve( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Duplicate Surface Curves"; } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // duplicateCurveUI // // Description: // Fill the contents of the option box for duplicate curve command. // // Input Arguments: // The name of the parent layout. // // Return Value: // None. // proc duplicateCurveUI(string $parent, string $goToTool) { setParent $parent; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performDuplicateCurve.kGroupWithOriginal")) localButton; radioButtonGrp -nrb 3 -label (uiRes("m_performDuplicateCurve.kVisibleSurfaceIsoparms")) -label1 (uiRes("m_performDuplicateCurve.kU")) -label2 (uiRes("m_performDuplicateCurve.kV")) -label3 (uiRes("m_performDuplicateCurve.kBoth")) isoparmsButton; if( "" != $goToTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performDuplicateCurve.kToolBehavior")) -label1 (uiRes("m_performDuplicateCurve.kExitOnCompletion")) -v1 on -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performDuplicateCurve.kAutoCompletion")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; radioButtonGrp -e -enable false isoparmsButton; } } // // Procedure Name: // duplicateCurveOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc duplicateCurveOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "duplicateCurve"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // The value returned is the name of the layout to be used as // the parent for the option box UI. // global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolDuplCurve"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "duplicateCurveToolScript 3"; 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. // duplicateCurveUI($parent, $goToTool); // Turn off the wait cursor. // waitCursor -state 0; // Deactivate the default UI template. // setUITemplate -popTemplate; // 'Duplicate' button. // string $applyBtn = getOptionBoxApplyBtn(); if( $inTheTool ) { button -edit -label (uiRes("m_performDuplicateCurve.kDuplicateTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performDuplicateCurve.kDuplicate")) -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_performDuplicateCurve.kDuplicateCurvesToolOptions")); } else { setOptionBoxTitle (uiRes("m_performDuplicateCurve.kDuplicateCurvesOptions")); } // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "DuplicateSurfaceCurves" ); // Set the current values of the option box. // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Show the option box. // showOptionBox(); } // // Procedure Name: // duplicateCurveHelp // // Description: // Returns a short description about the duplicate curve command. // // Input Arguments: // None. // // Return Value: // string. // proc string attachHelp() { return " Command: Duplicate Curve - make a 3D curve from a 2D curve.\n" + "Selection: curve on surface, surface isoparam, trimmed surface boundary."; } // // Procedure Name: // assembleCmd // // Description: // Construct the duplicate curve command that will apply the option // box values. // // Input Arguments: // None. // // Return Value: // The duplicate curve command string. // proc string assembleCmd() { setOptionVars(false); // query the settings for cmd(s). // string $version = "\"2\""; int $doHistory = `constructionHistory -q -tgl`; int $curveRangePartial = `optionVar -q duplicateCurveRangePartial`; int $local = `optionVar -q duplicateCurveLocal`; int $iso = `optionVar -q duplicateCurveIsoparms`; $cmd = "duplicateCurvePresetArgList" ; $cmd = $cmd + "( "; $cmd = $cmd + $version; $cmd = $cmd + ", {\"" ; $cmd = $cmd + $doHistory ; $cmd = $cmd + "\",\"" ; $cmd = $cmd + $curveRangePartial ; $cmd = $cmd + "\",\"" ; $cmd = $cmd + $local ; $cmd = $cmd + "\",\"" ; $cmd = $cmd + $iso ; $cmd = $cmd + "\"} )" ; return $cmd ; } global proc string performDuplicateCurve(int $action, string $goToTool) // // Description: // Perform the duplicate curve command using the appropriate // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the duplicate curve command with the current // option box values. // // Input Arguments: // $action = 0 ==>do the command. // $action = 1 ==>show option box. // $action = 2 ==>drag to shelf. // $action = 3 ==>set the button to enter the tool // // Return Value: // The duplicate curve command string. // { 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: duplicateCurveOptions( $inTheTool, $goToTool ); break; case 2: setOptionVars(false); $cmd = `assembleCmd`; break; } return $cmd; }