// =========================================================================== // 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 script contains the split shot option box dialogs. // proc setOptionVars (int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists splitShotTime` ) { optionVar -floatValue splitShotTime 0; } // splitShotTimeMethod: // 1: set the shot for the current time // 2: set the shot for the specified time // if ( $forceFactorySettings || !`optionVar -exists splitShotTimeMethod`) { optionVar -intValue splitShotTimeMethod 1; } } // // Procedure Name: // splitShotSetup // // 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 splitShotSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Set the start and end times. float $start = `optionVar -query splitShotTime`; floatFieldGrp -edit -value1 $start -enable false splitTimeValue; // Set the correct radio button. int $whichMethod = `optionVar -query splitShotTimeMethod`; switch($whichMethod) { case 1: radioButtonGrp -e -sl 1 currTimeMethod; break; case 2: radioButtonGrp -e -sl 1 specifyMethod; floatFieldGrp -edit -enable true splitTimeValue; break; default: radioButtonGrp -e -sl 1 currTimeMethod; break; } } // // Procedure Name: // splitShotCallback // // 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 splitShotCallback (string $parent, int $doIt, string $shots ) { setParent $parent; optionVar -floatValue splitShotTime `floatFieldGrp -query -value1 splitTimeValue`; if (`radioButtonGrp -q -sl currTimeMethod` == 1) { optionVar -intValue splitShotTimeMethod 1; } else if (`radioButtonGrp -q -sl specifyMethod` == 1) { optionVar -intValue splitShotTimeMethod 2; } if ($doIt) { performSplitShot 0 ("\"" + $shots + "\""); } } proc string splitShotWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adj true`; // shot start & duration string $splitTime = (uiRes("m_performSplitShot.kSplitTime")); radioButtonGrp -numberOfRadioButtons 1 -label $splitTime -label1 (uiRes("m_performSplitShot.kCurrentTime")) currTimeMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performSplitShot.kSpecifyTime")) -select 1 -shareCollection currTimeMethod -onCommand "floatFieldGrp -e -enable true splitTimeValue" -offCommand "floatFieldGrp -e -enable false splitTimeValue" specifyMethod; floatFieldGrp -label (uiRes("m_performSplitShot.kSplitTimeValue")) -numberOfFields 1 -parent $tabForm -columnAttach 1 "right" 5 -columnAttach 2 "left" 0 splitTimeValue; return $tabForm; } global proc splitShotOptions ( string $shots ) { string $commandName = "splitShot"; string $applyTitle = "Split"; // 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("shot"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; splitShotWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performSplitShot.kSplitShot")) -command ($callback + " " + $parent + " " + 1 + " " + $shots ) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " " + $shots + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_performSplitShot.kSplitShotOptions")); setOptionBoxHelpTag( "SplitShot" ); // 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 $shots ) { string $cmd; setOptionVars(false); string $splitMethod = "currTimeMethod"; int $whichMethod = `optionVar -q splitShotTimeMethod`; switch ($whichMethod) { case 1: $splitMethod = "currTimeMethod"; break; case 2: $splitMethod = "specifyMethod"; break; } float $time = `optionVar -query splitShotTime`; // doSplitShotArgList takes a string array // $cmd = "doSplitShotArgList 1 { " + "\"" + $splitMethod + "\"" + ",\"" + $time + "\"" + " } " +$shots ; return $cmd; } // // Procedure Name: // performSplitShot // // Description: // Split a shot 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 split a shot with the current option box values. // // Input Arguments: // $action: 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performSplitShot (int $action, string $shots ) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = assembleCmd($shots); // Execute the command with the option settings. // if ($cmd != "") evalEcho($cmd); break; // Show the option box. // case 1: splitShotOptions($shots); break; case 2: // Get the command. // $cmd = assembleCmd($shots); } return $cmd; }