// =========================================================================== // 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: Dec 3, 1996 // // Description: // This is a helper script to perform the setKeyframe command // using the various options that have been set // // 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) { // setKeyframeWhich: // 1 : set keyframes on all keyable attrs // 2 : set keyframes on all manip handle attrs // 3 : set keyframes on current manip handle // 4 : set keyframes on all manip handle attrs and all keyable attrs // if( $forceFactorySettings || !`optionVar -exists setKeyframeWhich` ) { optionVar -intValue setKeyframeWhich 4; } if( $forceFactorySettings || !`optionVar -exists setKeyframePrompt` ) { optionVar -intValue setKeyframePrompt 0; } if ( $forceFactorySettings || !`optionVar -exists keySetIKFK` ) { optionVar -intValue keySetIKFK 0; } if ( $forceFactorySettings || !`optionVar -exists keySetFBIK` ) { optionVar -intValue keySetFBIK 1; } if( $forceFactorySettings || !`optionVar -exists keyHierarchy`) { optionVar -intValue keyHierarchy 0; } // use channel box attrs // if ($forceFactorySettings || !`optionVar -exists keyUseChannelBox`) { optionVar -intValue keyUseChannelBox 0; } // -controlPoints // if ($forceFactorySettings || !`optionVar -exists keyControlPoints`) { optionVar -intValue keyControlPoints 0; } // -shape // if ($forceFactorySettings || !`optionVar -exists keyShapes`) { optionVar -intValue keyShapes 1; } } global proc setKeyframeSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // Query the optionVar's and set the values into the controls // int $whichAttrs = `optionVar -query setKeyframeWhich`; switch($whichAttrs) { case 1: radioButtonGrp -edit -select 1 allAttrsRB; break; case 2: radioButtonGrp -edit -select 1 allManipAttrsRB; break; case 3: radioButtonGrp -edit -select 1 curManipHandleRB; break; case 4: radioButtonGrp -edit -select 1 allManipOrAttrsRB; break; } if( `optionVar -query setKeyframePrompt` == 1 ) { radioButtonGrp -edit -select 2 setKeyframePrompt; } else { radioButtonGrp -edit -select 1 setKeyframePrompt; } checkBoxGrp -edit -value1 `optionVar -query keySetIKFK` setIKFKCB; checkBoxGrp -edit -value1 `optionVar -query keySetFBIK` setFBIKCB; if (`optionVar -query keyHierarchy` == 1) { radioButtonGrp -edit -select 2 hierarchyRB; } else { radioButtonGrp -edit -select 1 hierarchyRB; } if (`optionVar -query keyUseChannelBox` == 1) { radioButtonGrp -edit -select 2 channelsRB; } else { radioButtonGrp -edit -select 1 channelsRB; } checkBoxGrp -edit -value1 `optionVar -query keyControlPoints` controlCB; checkBoxGrp -edit -value1 `optionVar -query keyShapes` shapesCB; keyEnabling $parent ($whichAttrs == 1); } global proc setKeyframeCallback (string $parent, int $doIt, string $selectionConnection) // // Description: // Set the optionVar's from the control values, and then perform // the command // { setParent $parent; if( `radioButtonGrp -query -select allManipAttrsRB` == 1) { optionVar -intValue setKeyframeWhich 2; } else if( `radioButtonGrp -query -select curManipHandleRB` == 1 ) { optionVar -intValue setKeyframeWhich 3; } else if( `radioButtonGrp -query -select allAttrsRB` == 1 ) { optionVar -intValue setKeyframeWhich 1; } else { optionVar -intValue setKeyframeWhich 4; } if (`radioButtonGrp -query -select setKeyframePrompt` == 2) { optionVar -intValue setKeyframePrompt 1; } else { optionVar -intValue setKeyframePrompt 0; } optionVar -intValue keySetIKFK `checkBoxGrp -query -value1 setIKFKCB`; optionVar -intValue keySetFBIK `checkBoxGrp -query -value1 setFBIKCB`; if (`radioButtonGrp -query -select hierarchyRB` == 2) { optionVar -intValue keyHierarchy 1; } else { optionVar -intValue keyHierarchy 0; } if (`radioButtonGrp -query -select channelsRB` == 2) { optionVar -intValue keyUseChannelBox 1; } else { optionVar -intValue keyUseChannelBox 0; } optionVar -intValue keyControlPoints `checkBoxGrp -query -value1 controlCB`; optionVar -intValue keyShapes `checkBoxGrp -query -value1 shapesCB`; if ($doIt) { string $args[] = {(string) 0, $selectionConnection }; performSetKeyframeArgList 1 $args; string $tmpCmd = "performSetKeyframeArgList 1 " + "{ \"0\", "; $tmpCmd += "\"" + $selectionConnection + "\"}"; addToRecentCommandQueue $tmpCmd "SetKeyframe"; } } global proc keyEnabling(string $parent, int $state) { setParent $parent; radioButtonGrp -edit -enable $state hierarchyRB; radioButtonGrp -edit -enable $state channelsRB; keyChannelsEnabling $parent ($state && (`radioButtonGrp -query -select channelsRB` == 1)); } global proc keyChannelsEnabling(string $parent, int $state) { setParent $parent; checkBoxGrp -edit -enable $state controlCB; checkBoxGrp -edit -enable $state shapesCB; } global proc keyIKFKEnabling(string $parent, int $state) { setParent $parent; checkBoxGrp -edit -enable $state setIKFKCB; } proc string setKeyframeWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; // Make a collection of 4 radio groups instead of one with 4 options, // so that we can line up the text on separate lines // radioButtonGrp -numberOfRadioButtons 1 -columnWidth2 170 400 -label (uiRes("m_performSetKeyframeArgList.kSetKeysOn")) -label1 (uiRes("m_performSetKeyframeArgList.kAllManipHandlesKeyableAttrs")) allManipOrAttrsRB; radioButtonGrp -numberOfRadioButtons 1 -columnWidth2 170 400 -label1 (uiRes("m_performSetKeyframeArgList.kAllKeyableAttrs")) -changeCommand ("keyEnabling "+ $parent+" #1") -shareCollection allManipOrAttrsRB allAttrsRB; radioButtonGrp -numberOfRadioButtons 1 -columnWidth2 170 400 -label1 (uiRes("m_performSetKeyframeArgList.kAllManipHandles")) -shareCollection allManipOrAttrsRB allManipAttrsRB; radioButtonGrp -numberOfRadioButtons 1 -columnWidth2 170 400 -label1 (uiRes("m_performSetKeyframeArgList.kCurrentManipHandle")) -shareCollection allManipOrAttrsRB curManipHandleRB; radioButtonGrp -numberOfRadioButtons 2 -columnWidth3 170 160 200 -label (uiRes("m_performSetKeyframeArgList.kSetKeysAt")) -label1 (uiRes("m_performSetKeyframeArgList.kCurrentTime")) -label2 (uiRes("m_performSetKeyframeArgList.kPrompt")) -changeCommand1 ("keyIKFKEnabling "+ $parent+" #1") setKeyframePrompt; checkBoxGrp -label (uiRes("m_performSetKeyframeArgList.kSetIKFKKeys")) -numberOfCheckBoxes 1 -label1 "" setIKFKCB; checkBoxGrp -label (uiRes("m_performSetKeyframeArgList.kSetFBIKKeys")) -numberOfCheckBoxes 1 -label1 "" setFBIKCB; separator; radioButtonGrp -numberOfRadioButtons 2 -columnWidth3 170 160 200 -label (uiRes("m_performSetKeyframeArgList.kHierarchy")) -label1 (uiRes("m_performSetKeyframeArgList.kSelected")) -label2 (uiRes("m_performSetKeyframeArgList.kBelow")) hierarchyRB; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performSetKeyframeArgList.kChannels")) -columnWidth3 170 160 200 -label1 (uiRes("m_performSetKeyframeArgList.kAllKeyable")) -label2 (uiRes("m_performSetKeyframeArgList.kFromChannelBox")) -changeCommand1 ("keyChannelsEnabling " + $parent + " #1") channelsRB; checkBoxGrp -label (uiRes("m_performSetKeyframeArgList.kControlPoints")) -numberOfCheckBoxes 1 -label1 "" controlCB; checkBoxGrp -label (uiRes("m_performSetKeyframeArgList.kShapes")) -numberOfCheckBoxes 1 -label1 "" shapesCB; return $tabForm; } global proc setKeyframeOptions (string $selectionConnection) { string $commandName = "setKeyframe"; // 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($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scrollable true -tabsVisible false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; setKeyframeWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performSetKeyframeArgList.kSetKey")) -command ($callback + " " + $parent + " " + 1 + " \"" + $selectionConnection + "\"") $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " \"" + $selectionConnection + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle( (uiRes("m_performSetKeyframeArgList.kSetKeyOptions")) ); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "SetKey" ); // 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 $selectionConnection,int $zeroKeyForAnimLayer,int $setKeyInTimeEditor) { string $cmd; setOptionVars(false); // doSetKeyframeArgList takes a string array // $cmd = "doSetKeyframeArgList 7 { " + "\"" + `optionVar -query setKeyframeWhich` + "\"" + ",\"" + `optionVar -query keyHierarchy` + "\"" + ",\"" + `optionVar -query keyUseChannelBox` + "\"" + ",\"" + `optionVar -query keyControlPoints` + "\"" + ",\"" + `optionVar -query keyShapes` + "\"" + ",\"" + `optionVar -query setKeyframePrompt` + "\"" + ",\"" + false + "\"" + ",\"" + $selectionConnection + "\"" + ",\"" + `optionVar -query keySetIKFK` + "\"" + ",\"" + `optionVar -query keySetFBIK` + "\"" + ",\"" + $zeroKeyForAnimLayer + "\"" + ",\"" + $setKeyInTimeEditor + "\"" + " };"; return $cmd; } global proc string performSetKeyframeArgList (string $version, string $args[]) // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $action, $selectionConnection // // $args // Version 1 // [0] $action 0 - do the command // 1 - show the option box // 2 - return the drag command // 3 - do the command (triggered by time editor) // [1] $selectionConnection name of selection connection to use // // Version 2 // [2] $zeroKeyForAnimLayer whether or not to set a identity key for the selected // anim layer. // // Return Value: // The actual command to execute. // { int $versionNum = $version; int $action = $args[0]; string $selectionConnection = $args[1]; int $zeroKeyForAnimLayer = 0; if($versionNum > 1) { $zeroKeyForAnimLayer = $args[2]; } string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = assembleCmd ($selectionConnection,$zeroKeyForAnimLayer,0); // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: setKeyframeOptions ($selectionConnection); break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = assembleCmd ($selectionConnection,$zeroKeyForAnimLayer,0); break; // Execute the command (triggered by time editor). // case 3: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = assembleCmd ($selectionConnection,$zeroKeyForAnimLayer,1); // Execute the command with the option settings. // eval($cmd); break; } return $cmd; }