// =========================================================================== // 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: Oct 15, 1998 // // Description: // This script is the create character option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Character name // if ($forceFactorySettings || !`optionVar -exists createCharacterName`) { optionVar -stringValue createCharacterName "character1"; } if ($forceFactorySettings || !`optionVar -exists characterKeysToUse`) { optionVar -intValue characterKeysToUse 2; } // Which attrs to add to character // if ($forceFactorySettings || !`optionVar -exists characterExcTranslate`) { // exclude translate optionVar -intValue characterExcTranslate 0; } if ($forceFactorySettings || !`optionVar -exists characterExcRotate`) { // exclude rotate optionVar -intValue characterExcRotate 0; } if ($forceFactorySettings || !`optionVar -exists characterExcScale`) { // exclude scale optionVar -intValue characterExcScale 1; } if ($forceFactorySettings || !`optionVar -exists characterExcVis`) { // exclude visibility optionVar -intValue characterExcVis 1; } if ($forceFactorySettings || !`optionVar -exists characterExcDyn`) { // exclude dynamic optionVar -intValue characterExcDyn 0; } if ($forceFactorySettings || !`optionVar -exists characterHierarchy`) { // use hierarchy optionVar -intValue characterHierarchy 0; } if ($forceFactorySettings || !`optionVar -exists enableRedirection`) { // use selected as root optionVar -intValue enableRedirection 0; } if ($forceFactorySettings || !`optionVar -exists redirectRotation`) { // use selected as root optionVar -intValue redirectRotation 1; } if ($forceFactorySettings || !`optionVar -exists redirectTranslation`) { // use selected as root optionVar -intValue redirectTranslation 1; } } // // Procedure Name: // createCharacterSetup // // 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 createCharacterSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // name // string $name = `optionVar -query createCharacterName`; textFieldGrp -e -text $name characterNameWidget; int $exc_t = `optionVar -query characterExcTranslate`; checkBoxGrp -edit -value1 $exc_t excludeTranslateWidget; int $exc_r = `optionVar -query characterExcRotate`; checkBoxGrp -edit -value1 $exc_r excludeRotateWidget; int $exc_s = `optionVar -query characterExcScale`; checkBoxGrp -edit -value1 $exc_s excludeScaleWidget; int $exc_v = `optionVar -query characterExcVis`; checkBoxGrp -edit -value1 $exc_v excludeVisWidget; int $exc_d = `optionVar -query characterExcDyn`; checkBoxGrp -edit -value1 $exc_d excludeDynWidget; int $exc_total = $exc_t + $exc_r + $exc_s + $exc_v + $exc_d; int $useHier = `optionVar -query characterHierarchy`; int $keysToUse = `optionVar -q characterKeysToUse`; if ($keysToUse == 0) radioButtonGrp -edit -select 1 characterKeysWidget; else if ($keysToUse == 1) radioButtonGrp -edit -select 1 charChannelRB; else radioButtonGrp -edit -select 1 charExceptRB; if (0 == $exc_total) { radioButtonGrp -e -sl 1 characterKeysWidget; $keysToUse = 0; } if ($keysToUse != 2) { checkBoxGrp -edit -enable 0 excludeTranslateWidget; checkBoxGrp -edit -enable 0 excludeRotateWidget; checkBoxGrp -edit -enable 0 excludeScaleWidget; checkBoxGrp -edit -enable 0 excludeDynWidget; checkBoxGrp -edit -enable 0 excludeVisWidget; } else { checkBoxGrp -edit -enable 1 excludeTranslateWidget; checkBoxGrp -edit -enable 1 excludeRotateWidget; checkBoxGrp -edit -enable 1 excludeScaleWidget; checkBoxGrp -edit -enable 1 excludeDynWidget; checkBoxGrp -edit -enable 1 excludeVisWidget; } checkBoxGrp -edit -value1 `optionVar -query characterHierarchy` charHierWidget; checkBoxGrp -edit -enable ($keysToUse != 1) charHierWidget; int $makeRedirectable = `optionVar -query enableRedirection`; checkBoxGrp -edit -value1 $makeRedirectable makeRedirectableWidget; 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; } if ($makeRedirectable) { redirectionEnabledCB(); } else { redirectionDisabledCB(); } } // // Procedure Name: // createCharacterCallback // // 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 createCharacterCallback (string $parent, int $doIt) { setParent $parent; // Name // optionVar -stringValue createCharacterName `textFieldGrp -q -text characterNameWidget`; int $keysToUse = `radioButtonGrp -q -sl characterKeysWidget`; int $channel = `radioButtonGrp -q -sl charChannelRB`; if ($keysToUse) { optionVar -intValue characterKeysToUse 0; } else if ($channel) { optionVar -intValue characterKeysToUse 1; } else { optionVar -intValue characterKeysToUse 2; } // which attrs to exclude in the character // optionVar -intValue characterExcTranslate `checkBoxGrp -q -value1 excludeTranslateWidget`; optionVar -intValue characterExcRotate `checkBoxGrp -q -value1 excludeRotateWidget`; optionVar -intValue characterExcScale `checkBoxGrp -q -value1 excludeScaleWidget`; optionVar -intValue characterExcVis `checkBoxGrp -q -value1 excludeVisWidget`; optionVar -intValue characterExcDyn `checkBoxGrp -q -value1 excludeDynWidget`; optionVar -intValue characterHierarchy `checkBoxGrp -q -value1 charHierWidget`; optionVar -intValue enableRedirection `checkBoxGrp -q -value1 makeRedirectableWidget`; 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) { performCreateCharacter false; addToRecentCommandQueue "performCreateCharacter false" "CreateCharacter"; } } global proc charAllKeyableOnCB() { checkBoxGrp -edit -enable 0 excludeTranslateWidget; checkBoxGrp -edit -enable 0 excludeRotateWidget; checkBoxGrp -edit -enable 0 excludeScaleWidget; checkBoxGrp -edit -enable 0 excludeVisWidget; checkBoxGrp -edit -enable 0 excludeDynWidget; int $keysToUse = `radioButtonGrp -q -sl charChannelRB`; checkBoxGrp -edit -enable ($keysToUse != 1) charHierWidget; } global proc charAllKeyableOffCB() { checkBoxGrp -edit -enable 1 excludeTranslateWidget; checkBoxGrp -edit -enable 1 excludeRotateWidget; checkBoxGrp -edit -enable 1 excludeScaleWidget; checkBoxGrp -edit -enable 1 excludeVisWidget; checkBoxGrp -edit -enable 1 excludeDynWidget; int $keysToUse = `radioButtonGrp -q -sl characterKeysWidget`; checkBoxGrp -edit -enable ($keysToUse != 1) charHierWidget; } global proc updateCharWidgetsCB() { int $exc_t = `checkBoxGrp -q -value1 excludeTranslateWidget`; int $exc_r = `checkBoxGrp -q -value1 excludeRotateWidget`; int $exc_s = `checkBoxGrp -q -value1 excludeScaleWidget`; int $exc_v = `checkBoxGrp -q -value1 excludeVisWidget`; int $exc_d = `checkBoxGrp -q -value1 excludeDynWidget`; int $exc_total = $exc_t + $exc_r + $exc_s + $exc_v + $exc_d; if (0 == $exc_total) { radioButtonGrp -e -sl 1 characterKeysWidget; } } global proc redirectionEnabledCB () { radioButtonGrp -edit -enable 1 redirectRotationTranslationRB; radioButtonGrp -edit -enable 1 redirectRotationRB; radioButtonGrp -edit -enable 1 redirectTranslationRB; } global proc redirectionDisabledCB () { radioButtonGrp -edit -enable 0 redirectRotationTranslationRB; radioButtonGrp -edit -enable 0 redirectRotationRB; radioButtonGrp -edit -enable 0 redirectTranslationRB; } proc string createCharacterWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; string $layout = `frameLayout -label (uiRes("m_performCreateCharacter.kCharacter")) -collapsable 0`; columnLayout; textFieldGrp -label (uiRes("m_performCreateCharacter.kName")) // Character names are used as node names and don't need to be translated. -text "character1" characterNameWidget; checkBoxGrp -label (uiRes("m_performCreateCharacter.kInclude")) -label1 (uiRes("m_performCreateCharacter.kHierarchyBelow")) -numberOfCheckBoxes 1 charHierWidget; setParent ..; setParent ..; $layout = `frameLayout -label (uiRes("m_performCreateCharacter.kAttributes")) -collapsable 0`; columnLayout; radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performCreateCharacter.kIncludeOptions")) -label1 (uiRes("m_performCreateCharacter.kAllKeyable")) -onc charAllKeyableOnCB characterKeysWidget; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCreateCharacter.kFromChannelBox")) -shareCollection characterKeysWidget -onc charAllKeyableOnCB charChannelRB; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCreateCharacter.kAllKeyableExcept")) -shareCollection characterKeysWidget -onc charAllKeyableOffCB charExceptRB; // which attributes to exclude in character string $form = `formLayout -numberOfDivisions 100 -width 450`; checkBoxGrp -label "" -label1 (uiRes("m_performCreateCharacter.kTranslate")) -numberOfCheckBoxes 1 -ofc updateCharWidgetsCB excludeTranslateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateCharacter.kRotate")) -numberOfCheckBoxes 1 -ofc updateCharWidgetsCB excludeRotateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateCharacter.kScale")) -numberOfCheckBoxes 1 -ofc updateCharWidgetsCB excludeScaleWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateCharacter.kVisibility")) -numberOfCheckBoxes 1 -ofc updateCharWidgetsCB excludeVisWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateCharacter.kDynamic")) -numberOfCheckBoxes 1 -ofc updateCharWidgetsCB excludeDynWidget; formLayout -edit -attachForm excludeTranslateWidget "left" 20 -attachNone excludeTranslateWidget "top" $form; formLayout -edit -attachForm excludeRotateWidget "left" 20 -attachControl excludeRotateWidget "top" 2 excludeTranslateWidget $form; formLayout -edit -attachForm excludeScaleWidget "left" 20 -attachControl excludeScaleWidget "top" 2 excludeRotateWidget $form; formLayout -edit -attachForm excludeVisWidget "left" 20 -attachControl excludeVisWidget "top" 2 excludeScaleWidget $form; formLayout -edit -attachForm excludeDynWidget "left" 20 -attachControl excludeDynWidget "top" 2 excludeVisWidget $form; setParent ..; setParent ..; setParent ..; $layout = `frameLayout -label (uiRes("m_performCreateCharacter.kRedirection")) -collapsable 0`; columnLayout; checkBoxGrp -label "" -label1 (uiRes("m_performCreateCharacter.kRedirectCharacter")) -numberOfCheckBoxes 1 -onc redirectionEnabledCB -ofc redirectionDisabledCB makeRedirectableWidget; $form = `formLayout -numberOfDivisions 100 -width 450`; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performCreateCharacter.kRotationTranslation")) redirectRotationTranslationRB; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performCreateCharacter.kRotation")) -shareCollection redirectRotationTranslationRB redirectRotationRB; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performCreateCharacter.kTranslation")) -shareCollection redirectRotationTranslationRB redirectTranslationRB; formLayout -edit -attachForm redirectRotationTranslationRB "left" 20 -attachNone redirectRotationTranslationRB "top" $form; formLayout -edit -attachForm redirectRotationRB "left" 20 -attachControl redirectRotationRB "top" 2 redirectRotationTranslationRB $form; formLayout -edit -attachForm redirectTranslationRB "left" 20 -attachControl redirectTranslationRB "top" 2 redirectRotationRB $form; setParent ..; setParent ..; setParent ..; return $tabForm; } global proc createCharacterOptions () { string $commandName = "createCharacter"; string $applyTitle = "Create"; // 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("character"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; createCharacterWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateCharacter.kCreateCharacterSet")) -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_performCreateCharacter.kCreateCharacterSetOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CharacterCreate" ); // 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; setOptionVars(false); // get the partition name string $characterName = "character1"; if (`optionVar -exists createCharacterName`) { $characterName = `optionVar -query createCharacterName`; } int $excludeTranslate = 0; int $excludeRotate = 0; int $excludeScale = 0; int $excludeVisibility = 0; int $excludeDynamic = 0; int $useChannelBox = 0; int $useHierarchy = 0; int $enableRedirection = 0; int $redirectionMode = 0; setOptionVars(false); if (`optionVar -exists characterKeysToUse`) { int $keysToUse = `optionVar -q characterKeysToUse`; if ($keysToUse == 1) { $useChannelBox = 1; } else { if ($keysToUse == 2) { if (`optionVar -exists characterExcTranslate`) { $excludeTranslate = (`optionVar -query characterExcTranslate`); } if (`optionVar -exists characterExcRotate`) { $excludeRotate = (`optionVar -query characterExcRotate`); } if (`optionVar -exists characterExcScale`) { $excludeScale = (`optionVar -query characterExcScale`); } if (`optionVar -exists characterExcVis`) { $excludeVisibility = (`optionVar -query characterExcVis`); } if (`optionVar -exists characterExcDyn`) { $excludeDynamic = (`optionVar -query characterExcDyn`); } } if (`optionVar -exists characterHierarchy`) { $useHierarchy = `optionVar -query characterHierarchy`; } if (`optionVar -exists enableRedirection`) { $enableRedirection = `optionVar -query enableRedirection`; } if (`optionVar -exists animationOffsetMode`) { $redirectionMode = `optionVar -query animationOffsetMode`; } } } // doCreateCharacterArgList takes a string array // $cmd = "doCreateCharacterArgList 4 { " + "\"" + $characterName + "\"" + ",\"" + $excludeTranslate + "\"" + ",\"" + $excludeRotate + "\"" + ",\"" + $excludeScale + "\"" + ",\"" + $excludeVisibility + "\"" + ",\"" + $excludeDynamic + "\"" + ",\"" + $useChannelBox + "\"" + ",\"" + $useHierarchy + "\"" + ",\"" + $enableRedirection + "\"" + ",\"" + $redirectionMode + "\"" + " };"; return $cmd; } // // Procedure Name: // performCreateCharacter // // 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 performCreateCharacter (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: createCharacterOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }