// =========================================================================== // 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. // =========================================================================== // Description: // This is a helper script to setup the UI option box for adding // items to animation layers // // Input Arguments: // int action 0 - just execute the command // 1 - show the option box dialog // 2 - return the drag command // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsAttributesToUse`) { optionVar -intValue animLayerAddObjectsAttributesToUse 0; } if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsExcTranslate`) { // exclude translate optionVar -intValue animLayerAddObjectsExcTranslate 0; } if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsExcRotate`) { // exclude rotate optionVar -intValue animLayerAddObjectsExcRotate 0; } if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsExcScale`) { // exclude scale optionVar -intValue animLayerAddObjectsExcScale 1; } if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsExcDyn`) { // exclude dynamic optionVar -intValue animLayerAddObjectsExcDyn 0; } if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsExcBool`) { // exclude booleans optionVar -intValue animLayerAddObjectsExcBool 0; } if ($forceFactorySettings || !`optionVar -exists animLayerAddObjectsExcEnum`) { // exclude enums optionVar -intValue animLayerAddObjectsExcEnum 0; } } // // Procedure Name: // animLayerAddObjectsSetup // // 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 animLayerAddObjectsSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; int $exc_t = `optionVar -query animLayerAddObjectsExcTranslate`; checkBoxGrp -edit -value1 $exc_t animLayerAddObjectsExcludeTranslateWidget; int $exc_r = `optionVar -query animLayerAddObjectsExcRotate`; checkBoxGrp -edit -value1 $exc_r animLayerAddObjectsExcludeRotateWidget; int $exc_s = `optionVar -query animLayerAddObjectsExcScale`; checkBoxGrp -edit -value1 $exc_s animLayerAddObjectsExcludeScaleWidget; int $exc_d = `optionVar -query animLayerAddObjectsExcDyn`; checkBoxGrp -edit -value1 $exc_d animLayerAddObjectsExcludeDynWidget; int $exc_b = `optionVar -query animLayerAddObjectsExcBool`; checkBoxGrp -edit -value1 $exc_b animLayerAddObjectsExcludeBoolWidget; int $exc_e = `optionVar -query animLayerAddObjectsExcEnum`; checkBoxGrp -edit -value1 $exc_e animLayerAddObjectsExcludeEnumWidget; int $exc_total = $exc_t + $exc_r + $exc_s + $exc_d + $exc_b + $exc_e; int $attrsToUse = `optionVar -q animLayerAddObjectsAttributesToUse`; if ($attrsToUse == 0) radioButtonGrp -edit -select 1 animLayerAddObjectsAllKeyableRB; else if ($attrsToUse == 1) radioButtonGrp -edit -select 1 animLayerAddObjectsChannelBoxRB; else radioButtonGrp -edit -select 1 animLayerAddObjectsAllKeyableExceptRB; if (0 == $exc_total) { radioButtonGrp -e -sl 1 animLayerAddObjectsAllKeyableRB; optionVar -intValue animLayerAddObjectsAttributesToUse 0; } if (`optionVar -q animLayerAddObjectsAttributesToUse` != 2) { checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeTranslateWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeRotateWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeScaleWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeDynWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeBoolWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeEnumWidget; } else { checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeTranslateWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeRotateWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeScaleWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeDynWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeBoolWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeEnumWidget; } } global proc updateOptionVarsFromUI() { int $allKeyable = `radioButtonGrp -q -sl animLayerAddObjectsAllKeyableRB`; int $channel = `radioButtonGrp -q -sl animLayerAddObjectsChannelBoxRB`; if ($allKeyable) { optionVar -intValue animLayerAddObjectsAttributesToUse 0; } else if ($channel) { optionVar -intValue animLayerAddObjectsAttributesToUse 1; } else { optionVar -intValue animLayerAddObjectsAttributesToUse 2; } // which attrs to exclude in the character // optionVar -intValue animLayerAddObjectsExcTranslate `checkBoxGrp -q -value1 animLayerAddObjectsExcludeTranslateWidget`; optionVar -intValue animLayerAddObjectsExcRotate `checkBoxGrp -q -value1 animLayerAddObjectsExcludeRotateWidget`; optionVar -intValue animLayerAddObjectsExcScale `checkBoxGrp -q -value1 animLayerAddObjectsExcludeScaleWidget`; optionVar -intValue animLayerAddObjectsExcDyn `checkBoxGrp -q -value1 animLayerAddObjectsExcludeDynWidget`; optionVar -intValue animLayerAddObjectsExcBool `checkBoxGrp -q -value1 animLayerAddObjectsExcludeBoolWidget`; optionVar -intValue animLayerAddObjectsExcEnum `checkBoxGrp -q -value1 animLayerAddObjectsExcludeEnumWidget`; } // // Procedure Name: // animLayerAddObjectsCallback // // 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 animLayerAddObjectsCallback (string $parent, int $doIt) { setParent $parent; updateOptionVarsFromUI(); if ($doIt) { performAnimLayerAddObjects 0; //FIXME: addToRecentCommandQueue "performAnimLayerAddObjects false" "CreateCharacter"; } } global proc animLayerAddObjectsAllKeyableOnCB() { checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeTranslateWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeRotateWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeScaleWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeDynWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeBoolWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeEnumWidget; updateOptionVarsFromUI(); } global proc animLayerAddObjectsFromChannelBoxCB() { checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeTranslateWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeRotateWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeScaleWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeDynWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeBoolWidget; checkBoxGrp -edit -enable 0 animLayerAddObjectsExcludeEnumWidget; updateOptionVarsFromUI(); } global proc animLayerAddObjectsAllKeyableOffCB() { checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeTranslateWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeRotateWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeScaleWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeDynWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeBoolWidget; checkBoxGrp -edit -enable 1 animLayerAddObjectsExcludeEnumWidget; updateOptionVarsFromUI(); } global proc updateAnimLayerAddObjectsWidgetsCB() { int $exc_t = `checkBoxGrp -q -value1 animLayerAddObjectsExcludeTranslateWidget`; int $exc_r = `checkBoxGrp -q -value1 animLayerAddObjectsExcludeRotateWidget`; int $exc_s = `checkBoxGrp -q -value1 animLayerAddObjectsExcludeScaleWidget`; int $exc_d = `checkBoxGrp -q -value1 animLayerAddObjectsExcludeDynWidget`; int $exc_b = `checkBoxGrp -q -value1 animLayerAddObjectsExcludeBoolWidget`; int $exc_e = `checkBoxGrp -q -value1 animLayerAddObjectsExcludeEnumWidget`; int $exc_total = $exc_t + $exc_r + $exc_s + $exc_d + $exc_b + $exc_e; if (0 == $exc_total) { radioButtonGrp -e -sl 1 animLayerAddObjectsAllKeyableRB; } updateOptionVarsFromUI(); } proc string createAnimLayerAddObjectsWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; $layout = `frameLayout -label (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsAttributes")) -collapsable 0`; columnLayout; radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsIncludeOptions")) -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsAllKeyable")) -onc animLayerAddObjectsAllKeyableOnCB animLayerAddObjectsAllKeyableRB; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsFromChannelBox")) -shareCollection animLayerAddObjectsAllKeyableRB -onc animLayerAddObjectsFromChannelBoxCB animLayerAddObjectsChannelBoxRB; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsAllKeyableExcept")) -shareCollection animLayerAddObjectsAllKeyableRB -onc animLayerAddObjectsAllKeyableOffCB animLayerAddObjectsAllKeyableExceptRB; // which attributes to exclude in character string $form = `formLayout -numberOfDivisions 100 -width 450`; checkBoxGrp -label "" -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsTranslate")) -numberOfCheckBoxes 1 -ofc updateAnimLayerAddObjectsWidgetsCB -onc updateAnimLayerAddObjectsWidgetsCB animLayerAddObjectsExcludeTranslateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsRotate")) -numberOfCheckBoxes 1 -ofc updateAnimLayerAddObjectsWidgetsCB -onc updateAnimLayerAddObjectsWidgetsCB animLayerAddObjectsExcludeRotateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsScale")) -numberOfCheckBoxes 1 -ofc updateAnimLayerAddObjectsWidgetsCB -onc updateAnimLayerAddObjectsWidgetsCB animLayerAddObjectsExcludeScaleWidget; checkBoxGrp -label "" -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsDynamic")) -numberOfCheckBoxes 1 -ofc updateAnimLayerAddObjectsWidgetsCB -onc updateAnimLayerAddObjectsWidgetsCB animLayerAddObjectsExcludeDynWidget; checkBoxGrp -label "" -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsBoolean")) -numberOfCheckBoxes 1 -ofc updateAnimLayerAddObjectsWidgetsCB -onc updateAnimLayerAddObjectsWidgetsCB animLayerAddObjectsExcludeBoolWidget; checkBoxGrp -label "" -label1 (uiRes("m_performAnimLayerAddObjects.kAnimLayerAddObjectsEnum")) -numberOfCheckBoxes 1 -ofc updateAnimLayerAddObjectsWidgetsCB -onc updateAnimLayerAddObjectsWidgetsCB animLayerAddObjectsExcludeEnumWidget; formLayout -edit -attachForm animLayerAddObjectsExcludeTranslateWidget "left" 20 -attachNone animLayerAddObjectsExcludeTranslateWidget "top" $form; formLayout -edit -attachForm animLayerAddObjectsExcludeRotateWidget "left" 20 -attachControl animLayerAddObjectsExcludeRotateWidget "top" 2 animLayerAddObjectsExcludeTranslateWidget $form; formLayout -edit -attachForm animLayerAddObjectsExcludeScaleWidget "left" 20 -attachControl animLayerAddObjectsExcludeScaleWidget "top" 2 animLayerAddObjectsExcludeRotateWidget $form; formLayout -edit -attachForm animLayerAddObjectsExcludeDynWidget "left" 20 -attachControl animLayerAddObjectsExcludeDynWidget "top" 2 animLayerAddObjectsExcludeScaleWidget $form; formLayout -edit -attachForm animLayerAddObjectsExcludeBoolWidget "left" 20 -attachControl animLayerAddObjectsExcludeBoolWidget "top" 2 animLayerAddObjectsExcludeDynWidget $form; formLayout -edit -attachForm animLayerAddObjectsExcludeEnumWidget "left" 20 -attachControl animLayerAddObjectsExcludeEnumWidget "top" 2 animLayerAddObjectsExcludeBoolWidget $form; return $tabForm; } global proc animLayerAddObjectsOptions () { string $commandName = "animLayerAddObjects"; // 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("animLayer"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; createAnimLayerAddObjectsWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -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_performAnimLayerAddObjects.kAnimLayerAddObjectsOptions")); setOptionBoxHelpTag("AnimLayerAddObjects"); // 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); int $attrsToUse = 0; int $excludeTranslate = 0; int $excludeRotate = 0; int $excludeScale = 0; int $excludeDynamic = 0; int $excludeBool = 0; int $excludeEnum = 0; int $useChannelBox = 0; setOptionVars(false); if (`optionVar -exists animLayerAddObjectsAttributesToUse`) { $attrsToUse = `optionVar -q animLayerAddObjectsAttributesToUse`; if ($attrsToUse == 1) { $useChannelBox = 1; } else { if ($attrsToUse == 2) { if (`optionVar -exists animLayerAddObjectsExcTranslate`) { $excludeTranslate = (`optionVar -query animLayerAddObjectsExcTranslate`); } if (`optionVar -exists animLayerAddObjectsExcRotate`) { $excludeRotate = (`optionVar -query animLayerAddObjectsExcRotate`); } if (`optionVar -exists animLayerAddObjectsExcScale`) { $excludeScale = (`optionVar -query animLayerAddObjectsExcScale`); } if (`optionVar -exists animLayerAddObjectsExcDyn`) { $excludeDynamic = (`optionVar -query animLayerAddObjectsExcDyn`); } if (`optionVar -exists animLayerAddObjectsExcBool`) { $excludeBool = (`optionVar -query animLayerAddObjectsExcBool`); } if (`optionVar -exists animLayerAddObjectsExcEnum`) { $excludeEnum = (`optionVar -query animLayerAddObjectsExcEnum`); } } } } // doCreateCharacterArgList takes a string array // $cmd = "doAnimLayerAddObjectsArgList 1 { " + "\"" + $attrsToUse + "\"" + ",\"" + $excludeTranslate + "\"" + ",\"" + $excludeRotate + "\"" + ",\"" + $excludeScale + "\"" + ",\"" + $excludeDynamic + "\"" + ",\"" + $excludeBool + "\"" + ",\"" + $excludeEnum + "\"" + " };"; return $cmd; } // // Procedure Name: // performAnimLayerAddObjects // // Description: // Creates the UI to add an object to animation layers. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performAnimLayerAddObjects (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: animLayerAddObjectsOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }