// =========================================================================== // 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 setKey -breakdown true 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) { // setBreakdownWhich: // 1 : set keyframes on all keyable attrs // 2 : set keyframes on all manip handle attrs // 3 : set keyframes on current manip handle // if( $forceFactorySettings || !`optionVar -exists setBreakdownWhich` ) { optionVar -intValue setBreakdownWhich 1; } if( $forceFactorySettings || !`optionVar -exists setBreakdownPrompt` ) { optionVar -intValue setBreakdownPrompt 0; } if( $forceFactorySettings || !`optionVar -exists setBreakdownHierarchy`) { optionVar -intValue setBreakdownHierarchy 0; } // use channel box attrs // if ($forceFactorySettings || !`optionVar -exists setBreakdownUseChannelBox`) { optionVar -intValue setBreakdownUseChannelBox 0; } // -controlPoints // if ($forceFactorySettings || !`optionVar -exists setBreakdownControlPoints`) { optionVar -intValue setBreakdownControlPoints 0; } // -shape // if ($forceFactorySettings || !`optionVar -exists setBreakdownShapes`) { optionVar -intValue setBreakdownShapes 1; } } global proc setBreakdownSetup (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 setBreakdownWhich`; 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; } if( `optionVar -query setBreakdownPrompt` == 1 ) { radioButtonGrp -edit -select 2 setBreakdownPrompt; } else { radioButtonGrp -edit -select 1 setBreakdownPrompt; } if (`optionVar -query setBreakdownHierarchy` == 1) { radioButtonGrp -edit -select 2 hierarchyRB; } else { radioButtonGrp -edit -select 1 hierarchyRB; } if (`optionVar -query setBreakdownUseChannelBox` == 1) { radioButtonGrp -edit -select 2 channelsRB; } else { radioButtonGrp -edit -select 1 channelsRB; } checkBoxGrp -edit -value1 `optionVar -query setBreakdownControlPoints` controlCB; checkBoxGrp -edit -value1 `optionVar -query setBreakdownShapes` shapesCB; breakdownEnabling $parent ($whichAttrs == 1); } global proc setBreakdownCallback (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 setBreakdownWhich 2; } else if( `radioButtonGrp -query -select curManipHandleRB` == 1 ) { optionVar -intValue setBreakdownWhich 3; } else { optionVar -intValue setBreakdownWhich 1; } if (`radioButtonGrp -query -select setBreakdownPrompt` == 2) { optionVar -intValue setBreakdownPrompt 1; } else { optionVar -intValue setBreakdownPrompt 0; } if (`radioButtonGrp -query -select hierarchyRB` == 2) { optionVar -intValue setBreakdownHierarchy 1; } else { optionVar -intValue setBreakdownHierarchy 0; } if (`radioButtonGrp -query -select channelsRB` == 2) { optionVar -intValue setBreakdownUseChannelBox 1; } else { optionVar -intValue setBreakdownUseChannelBox 0; } optionVar -intValue setBreakdownControlPoints `checkBoxGrp -query -value1 controlCB`; optionVar -intValue setBreakdownShapes `checkBoxGrp -query -value1 shapesCB`; if ($doIt) { performSetBreakdown 0 $selectionConnection; string $tmpCmd = "performSetBreakdown 0 \"" + $selectionConnection + "\""; addToRecentCommandQueue $tmpCmd "SetBreakdown"; } } global proc breakdownEnabling(string $parent, int $state) { setParent $parent; radioButtonGrp -edit -enable $state hierarchyRB; radioButtonGrp -edit -enable $state channelsRB; breakdownChannelsEnabling $parent ($state && (`radioButtonGrp -query -select channelsRB` == 1)); } global proc breakdownChannelsEnabling(string $parent, int $state) { setParent $parent; checkBoxGrp -edit -enable $state controlCB; checkBoxGrp -edit -enable $state shapesCB; } proc string setBreakdownWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; // Make a collection of 3 radio groups instead of one with 3 options, // so that we can line up the text on separate lines // radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performSetBreakdown.kSetBreakdownson")) -label1 (uiRes("m_performSetBreakdown.kAllKeyableAttrs")) -changeCommand ("breakdownEnabling "+ $parent+" #1") allAttrsRB; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performSetBreakdown.kAllManipHandles")) -shareCollection allAttrsRB allManipAttrsRB; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performSetBreakdown.kCurrentManipHandle")) -shareCollection allAttrsRB curManipHandleRB; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performSetBreakdown.kSetBreakdownsAt")) -label1 (uiRes("m_performSetBreakdown.kCurrentTime")) -label2 (uiRes("m_performSetBreakdown.kPrompt")) setBreakdownPrompt; separator; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performSetBreakdown.kHierarchy")) -label1 (uiRes("m_performSetBreakdown.kSelected")) -label2 (uiRes("m_performSetBreakdown.kBelow")) hierarchyRB; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performSetBreakdown.kChannels")) -label1 (uiRes("m_performSetBreakdown.kAllKeyable")) -label2 (uiRes("m_performSetBreakdown.kFromChannelBox")) -changeCommand1 ("breakdownChannelsEnabling " + $parent + " #1") channelsRB; checkBoxGrp -label (uiRes("m_performSetBreakdown.kControlPoints")) -numberOfCheckBoxes 1 -label1 "" controlCB; checkBoxGrp -label (uiRes("m_performSetBreakdown.kShapes")) -numberOfCheckBoxes 1 -label1 "" shapesCB; return $tabForm; } global proc setBreakdownOptions (string $selectionConnection) { string $commandName = "setBreakdown"; // 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`; setBreakdownWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performSetBreakdown.kSetBreakdown")) -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_performSetBreakdown.kSetBreakdownOptions")) ); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "SetBreakdown" ); // 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) { string $cmd; setOptionVars(false); // doSetKeyframeArgList takes a string array // $cmd = "doSetKeyframeArgList 3 { " + "\"" + `optionVar -query setBreakdownWhich` + "\"" + ",\"" + `optionVar -query setBreakdownHierarchy` + "\"" + ",\"" + `optionVar -query setBreakdownUseChannelBox` + "\"" + ",\"" + `optionVar -query setBreakdownControlPoints` + "\"" + ",\"" + `optionVar -query setBreakdownShapes` + "\"" + ",\"" + `optionVar -query setBreakdownPrompt` + "\"" + ",\"" + true + "\"" + ",\"" + $selectionConnection + "\"" + " };"; return $cmd; } // // Procedure Name: // performSetBreakdown // // Description: // Perform the 'setKeyframe -breakdown true' command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the 'setKeyframe -breakdown true' command 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 performSetBreakdown (int $action, string $selectionConnection) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = assembleCmd ($selectionConnection); // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: setBreakdownOptions ($selectionConnection); break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = assembleCmd ($selectionConnection); break; } return $cmd; }