// =========================================================================== // 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: Nov. 25, 2003 // // Description: // This script creates and manages the option box for the // "Redirect" menu item. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists animationOffsetMode`) { // use selected as root optionVar -intValue animationOffsetMode 0; } } // // Procedure Name: // makeRedirectableSetup // // 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 makeRedirectableSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; int $redirectionMode = `optionVar -query animationOffsetMode`; if ($redirectionMode == 0) { radioButtonGrp -edit -select 1 redirectRotationTranslationRB; } else if ($redirectionMode == 1) { radioButtonGrp -edit -select 1 redirectRotationRB; } else if ($redirectionMode == 2) { radioButtonGrp -edit -select 1 redirectTranslationRB; } } // // Procedure Name: // makeRedirectableCallback // // 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 makeRedirectableCallback (string $parent, int $doIt) { setParent $parent; if (`radioButtonGrp -q -sl redirectRotationTranslationRB`) { optionVar -intValue animationOffsetMode 0; } else if (`radioButtonGrp -q -sl redirectRotationRB`) { optionVar -intValue animationOffsetMode 1; } else if (`radioButtonGrp -q -sl redirectTranslationRB`) { optionVar -intValue animationOffsetMode 2; } if ($doIt) { performAddAnimationOffset false; addToRecentCommandQueue "performAddAnimationOffset false" "AddAnimationOffset"; } } proc string createWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; string $layout = `frameLayout -label (uiRes("m_performAddAnimationOffset.kRedirectionType")) -collapsable 0`; columnLayout; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performAddAnimationOffset.kRotationTranslation")) redirectRotationTranslationRB; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performAddAnimationOffset.kRotation")) -shareCollection redirectRotationTranslationRB redirectRotationRB; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performAddAnimationOffset.kTranslation")) -shareCollection redirectRotationTranslationRB redirectTranslationRB; setParent ..; setParent ..; setParent ..; return $tabForm; } global proc makeRedirectableOptions () { string $commandName = "makeRedirectable"; string $applyTitle = "Redirect"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // // 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; setOptionBoxCommandName("redirect"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; createWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAddAnimationOffset.kRedirect")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_performAddAnimationOffset.kCharacterRedirectionOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "Redirect" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // 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; int $redirectionMode = 0; setOptionVars(false); if (`optionVar -exists animationOffsetMode`) { $redirectionMode = `optionVar -query animationOffsetMode`; } string $currentSelection[] = `ls -selection`; string $root = $currentSelection[0]; $cmd = "doAddAnimationOffsetArgList 1 {" + "\"" + $root + "\" " + ",\"" + $redirectionMode + "\" " + " };"; return $cmd; } // // Procedure Name: // performAddAnimationOffset // // Description: // Create a character and add the animatable attributes from the // selected nodes. This procedure will also show the option box // window if necessary as well as construct the command string // that will create a character with the current option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performAddAnimationOffset (int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: makeRedirectableOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }