// =========================================================================== // 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 subCharacter option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // SubCharacter name // if ($forceFactorySettings || !`optionVar -exists createSubCharacterName`) { optionVar -stringValue createSubCharacterName "subCharacter1"; } if ($forceFactorySettings || !`optionVar -exists subCharacterKeysToUse`) { optionVar -intValue subCharacterKeysToUse 2; } // Which attrs to add to subCharacter // if ($forceFactorySettings || !`optionVar -exists subCharacterExcTranslate`) { // exclude translate optionVar -intValue subCharacterExcTranslate 0; } if ($forceFactorySettings || !`optionVar -exists subCharacterExcRotate`) { // exclude rotate optionVar -intValue subCharacterExcRotate 0; } if ($forceFactorySettings || !`optionVar -exists subCharacterExcScale`) { // exclude scale optionVar -intValue subCharacterExcScale 1; } if ($forceFactorySettings || !`optionVar -exists subCharacterExcVis`) { // exclude visibility optionVar -intValue subCharacterExcVis 1; } if ($forceFactorySettings || !`optionVar -exists subCharacterExcDyn`) { // exclude dynamic optionVar -intValue subCharacterExcDyn 0; } } // // Procedure Name: // createSubCharacterSetup // // 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 createSubCharacterSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // name // string $name = `optionVar -query createSubCharacterName`; textFieldGrp -e -text $name subCharacterNameWidget; int $exc_t = `optionVar -query subCharacterExcTranslate`; checkBoxGrp -edit -value1 $exc_t excludeTranslateWidget; int $exc_r = `optionVar -query subCharacterExcRotate`; checkBoxGrp -edit -value1 $exc_r excludeRotateWidget; int $exc_s = `optionVar -query subCharacterExcScale`; checkBoxGrp -edit -value1 $exc_s excludeScaleWidget; int $exc_v = `optionVar -query subCharacterExcVis`; checkBoxGrp -edit -value1 $exc_v excludeVisWidget; int $exc_d = `optionVar -query subCharacterExcDyn`; checkBoxGrp -edit -value1 $exc_d excludeDynWidget; int $exc_total = $exc_t + $exc_r + $exc_s + $exc_v + $exc_d; int $keysToUse = `optionVar -q subCharacterKeysToUse`; if ($keysToUse == 0) radioButtonGrp -edit -select 1 subCharacterKeysWidget; else if ($keysToUse == 1) radioButtonGrp -edit -select 1 charChannelRB; else radioButtonGrp -edit -select 1 charExceptRB; if (0 == $exc_total) { radioButtonGrp -e -sl 1 subCharacterKeysWidget; $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; } } // // Procedure Name: // createSubCharacterCallback // // 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 createSubCharacterCallback (string $parent, int $doIt) { setParent $parent; // Name // optionVar -stringValue createSubCharacterName `textFieldGrp -q -text subCharacterNameWidget`; int $keysToUse = `radioButtonGrp -q -sl subCharacterKeysWidget`; int $channel = `radioButtonGrp -q -sl charChannelRB`; if ($keysToUse) { optionVar -intValue subCharacterKeysToUse 0; } else if ($channel) { optionVar -intValue subCharacterKeysToUse 1; } else { optionVar -intValue subCharacterKeysToUse 2; } // which attrs to exclude in the subCharacter // optionVar -intValue subCharacterExcTranslate `checkBoxGrp -q -value1 excludeTranslateWidget`; optionVar -intValue subCharacterExcRotate `checkBoxGrp -q -value1 excludeRotateWidget`; optionVar -intValue subCharacterExcScale `checkBoxGrp -q -value1 excludeScaleWidget`; optionVar -intValue subCharacterExcVis `checkBoxGrp -q -value1 excludeVisWidget`; optionVar -intValue subCharacterExcDyn `checkBoxGrp -q -value1 excludeDynWidget`; if ($doIt) { performCreateSubcharacter false; addToRecentCommandQueue "performCreateSubcharacter false" "CreateSubCharacter"; } } global proc subcharAllKeyableOnCB() { 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; } global proc subcharAllKeyableOffCB() { 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; } global proc updateSubCharWidgetsCB() { 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 subCharacterKeysWidget; } } proc string createSubCharacterWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; textFieldGrp -label (uiRes("m_performCreateSubcharacter.kName")) // Node name doesn't need to be translated. -text "subCharacter1" subCharacterNameWidget; radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performCreateSubcharacter.kCSubcharacterSet")) -label1 (uiRes("m_performCreateSubcharacter.kAllKeyable")) -onc subcharAllKeyableOnCB subCharacterKeysWidget; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCreateSubcharacter.kFromChannelBox")) -shareCollection subCharacterKeysWidget -onc subcharAllKeyableOnCB charChannelRB; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCreateSubcharacter.kAllKeyableExcept")) -shareCollection subCharacterKeysWidget -onc subcharAllKeyableOffCB charExceptRB; // which attributes to exclude in subCharacter checkBoxGrp -label "" -label1 (uiRes("m_performCreateSubcharacter.kNoTranslate")) -numberOfCheckBoxes 1 -ofc updateSubCharWidgetsCB excludeTranslateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateSubcharacter.kNoRotate")) -numberOfCheckBoxes 1 -ofc updateSubCharWidgetsCB excludeRotateWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateSubcharacter.kNoScale")) -numberOfCheckBoxes 1 -ofc updateSubCharWidgetsCB excludeScaleWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateSubcharacter.kNoVisibility")) -numberOfCheckBoxes 1 -ofc updateSubCharWidgetsCB excludeVisWidget; checkBoxGrp -label "" -label1 (uiRes("m_performCreateSubcharacter.kNoDynamic")) -numberOfCheckBoxes 1 -ofc updateSubCharWidgetsCB excludeDynWidget; return $tabForm; } global proc createSubCharacterOptions () { string $commandName = "createSubCharacter"; 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`; createSubCharacterWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateSubcharacter.kCreateSubcharacterSet")) -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_performCreateSubcharacter.kCreateSubcharacterSetOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CreateSubcharacter" ); // 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 $subCharacterName = "subCharacter1"; if (`optionVar -exists createSubCharacterName`) { $subCharacterName = `optionVar -query createSubCharacterName`; } int $excludeTranslate = 0; int $excludeRotate = 0; int $excludeScale = 0; int $excludeVisibility = 0; int $excludeDynamic = 0; int $useChannelBox = 0; if (`optionVar -exists subCharacterKeysToUse`) { int $keysToUse = `optionVar -q subCharacterKeysToUse`; if ($keysToUse == 2) { if (`optionVar -exists subCharacterExcTranslate`) { $excludeTranslate = (`optionVar -query subCharacterExcTranslate`); } if (`optionVar -exists subCharacterExcRotate`) { $excludeRotate = (`optionVar -query subCharacterExcRotate`); } if (`optionVar -exists subCharacterExcScale`) { $excludeScale = (`optionVar -query subCharacterExcScale`); } if (`optionVar -exists subCharacterExcVis`) { $excludeVisibility = (`optionVar -query subCharacterExcVis`); } if (`optionVar -exists subCharacterExcDyn`) { $excludeDynamic = (`optionVar -query subCharacterExcDyn`); } } else if ($keysToUse == 1) { $useChannelBox = 1; } } // doCreateSubCharacterArgList takes a string array // $cmd = "doCreateSubcharacterArgList 2 { " + "\"" + $subCharacterName + "\"" + ",\"" + $excludeTranslate + "\"" + ",\"" + $excludeRotate + "\"" + ",\"" + $excludeScale + "\"" + ",\"" + $excludeVisibility + "\"" + ",\"" + $excludeDynamic + "\"" + ",\"" + $useChannelBox + "\"" + " };"; return $cmd; } // // Procedure Name: // performCreateSubcharacter // // Description: // Create a subCharacter 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 subCharacter 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 performCreateSubcharacter (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. // evalEcho($cmd); break; // Show the option box. // case 1: createSubCharacterOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }