// =========================================================================== // 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 surface menu item. // // Input Arguments: // int action // 0 - just execute the duplicate surface operation // 1 - show the option box dialog // 2 - drag to shelf // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists duplicateSurfaceLocal`) { optionVar -intValue duplicateSurfaceLocal 0; } } // // Procedure Name: // duplicateSurfaceSetup // // Description: // Update the state of the option box UI to reflect the duplicate surface // 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 duplicateSurfaceSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars($forceFactorySettings); duplicateSurfaceToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls. int $local = `optionVar -query duplicateSurfaceLocal`; checkBoxGrp -edit -v1 $local localButton; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -exitUponCompletion $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } // // Procedure Name: // duplicateSurfaceCallback // // 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 duplicateSurfaceCallback( string $parent, int $doIt, string $goToTool ) { if( "" != $goToTool ) { optionVar -iv duplicateSurfaceEuc `scriptCtx -q -euc $goToTool`; optionVar -iv duplicateSurfaceLac `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 duplicateSurfaceLocal $local; if( 1 == $doIt ) { performDuplicateSurface( 0, $goToTool ); } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // duplicateSurfaceUI // // Description: // Fill the contents of the option box for duplicate surface command. // // Input Arguments: // The name of the parent layout. // // Return Value: // None. // proc duplicateSurfaceUI(string $parent, string $goToTool) { setParent $parent; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performDuplicateSurface.kGroup")) localButton; if( "" != $goToTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performDuplicateSurface.kToolBehavior")) -label1 (uiRes("m_performDuplicateSurface.kExit")) -v1 on -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performDuplicateSurface.kAuto")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } } // // Procedure Name: // duplicateSurfaceOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc duplicateSurfaceOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "duplicateSurface"; // 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 = "modelWithToolDuplicateSurface"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "duplicateSurfaceToolScript 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. // duplicateSurfaceUI($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_performDuplicateSurface.kDuplicateTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performDuplicateSurface.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_performDuplicateSurface.kNURBSPatchesTool")); } else { setOptionBoxTitle (uiRes("m_performDuplicateSurface.kNURBSPatches")); } // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "DuplicateNURBSPatches" ); // Set the current values of the option box. // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Show the option box. // showOptionBox(); } // // Procedure Name: // duplicateSurfaceHelp // // Description: // Returns a short description about the duplicate surface command. // // Input Arguments: // None. // // Return Value: // string. // proc string attachHelp() { return " Command: Duplicate Surface - make a 3D surface from a 2D surface.\n" + "Selection: surface on surface, surface isoparam, trimmed surface boundary."; } // // Procedure Name: // assembleCmd // // Description: // Construct the duplicate surface command that will apply the option // box values. // // Input Arguments: // None. // // Return Value: // The duplicate surface command string. // proc string assembleCmd() { setOptionVars(false); // query the settings for cmd(s). // string $version = "\"2\""; int $doHistory = `constructionHistory -q -tgl`; int $local = `optionVar -q duplicateSurfaceLocal`; $cmd = "duplicateSurfacePresetArgList" ; $cmd = $cmd + "( "; $cmd = $cmd + $version; $cmd = $cmd + ", {\"" ; $cmd = $cmd + $doHistory ; $cmd = $cmd + "\",\"" ; $cmd = $cmd + $local ; $cmd = $cmd + "\"} )" ; return $cmd ; } global proc string performDuplicateSurface(int $action, string $goToTool) // // Description: // Perform the duplicate surface 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 surface 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 surface 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: duplicateSurfaceOptions( $inTheTool, $goToTool ); break; case 2: setOptionVars(false); $cmd = `assembleCmd`; break; } return $cmd; }