// =========================================================================== // 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: Jan 2, 2000 // // Description: // This script is the paste clip option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // pasteClipMethod: // 1: by attr name // 2: by attr order // 3: by node name // 4: using character map // if ( $forceFactorySettings || !`optionVar -exists pasteClipMethod`) { optionVar -intValue pasteClipMethod 4; } // timeMethod: // 1: currentTime // 2: start of timeline // 3: clipboard start time // if ( $forceFactorySettings || !`optionVar -exists pasteClipTimeMethod`) { optionVar -intValue pasteClipTimeMethod 3; } } // // Procedure Name: // pasteClipSetup // // 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 pasteClipSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Set the correct radio button. int $whichMethod = `optionVar -query pasteClipMethod`; switch($whichMethod) { case 1: radioButtonGrp -e -sl 1 byAttrNameMethod; break; case 2: radioButtonGrp -e -sl 1 byAttrOrderMethod; break; case 3: radioButtonGrp -e -sl 1 byNodeNameMethod; break; case 4: radioButtonGrp -e -sl 1 byCharMapMethod; break; default: radioButtonGrp -e -sl 1 byAttrNameMethod; break; } // Set the correct radio button. $whichMethod = `optionVar -query pasteClipTimeMethod`; switch($whichMethod) { case 1: radioButtonGrp -e -sl 1 currentTimeMethod; break; case 2: radioButtonGrp -e -sl 1 timelineStartMethod; break; case 3: radioButtonGrp -e -sl 1 clipboardStartMethod; break; default: radioButtonGrp -e -sl 1 clipboardStartMethod; break; } } // // Procedure Name: // pasteClipCallback // // 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 pasteClipCallback (string $parent, int $doIt) { setParent $parent; if (`radioButtonGrp -q -sl byAttrNameMethod` == 1) { optionVar -intValue pasteClipMethod 1; } else if (`radioButtonGrp -q -sl byAttrOrderMethod` == 1) { optionVar -intValue pasteClipMethod 2; } else if (`radioButtonGrp -q -sl byCharMapMethod` == 1) { optionVar -intValue pasteClipMethod 4; } else { optionVar -intValue pasteClipMethod 3; } if (`radioButtonGrp -q -sl currentTimeMethod` == 1) { optionVar -intValue pasteClipTimeMethod 1; } else if (`radioButtonGrp -q -sl timelineStartMethod` == 1) { optionVar -intValue pasteClipTimeMethod 2; } else { optionVar -intValue pasteClipTimeMethod 3; } if ($doIt) performPasteClip false; } proc string pasteClipWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adj true`; // how to do the paste radioButtonGrp -numberOfRadioButtons 1 -select 1 -label (uiRes("m_performPasteClip.kPasteMethod")) -label1 (uiRes("m_performPasteClip.kByAttributeName")) byAttrNameMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performPasteClip.kByAttributeOrder")) -shareCollection byAttrNameMethod byAttrOrderMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performPasteClip.kByNodeName")) -shareCollection byAttrNameMethod byNodeNameMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performPasteClip.kByCharacterMap")) -shareCollection byAttrNameMethod byCharMapMethod; // how to do the paste radioButtonGrp -numberOfRadioButtons 1 -select 1 -label (uiRes("m_performPasteClip.kStartFrame")) -label1 (uiRes("m_performPasteClip.kCurrentTime")) currentTimeMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performPasteClip.kTimelineStart")) -shareCollection currentTimeMethod timelineStartMethod; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performPasteClip.kClipboardStart")) -shareCollection currentTimeMethod clipboardStartMethod; return $tabForm; } global proc pasteClipOptions () { string $commandName = "pasteClip"; string $applyTitle = "Paste"; // 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("clip"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; pasteClipWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performPasteClip.kPasteClip")) -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_performPasteClip.kPasteClipOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "PastClip" ); // 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); string $pasteMethod = "byAttrName"; int $whichMethod = `optionVar -q pasteClipMethod`; switch ($whichMethod) { case 1: $pasteMethod = "byAttrName"; break; case 2: $pasteMethod = "byAttrOrder"; break; case 3: $pasteMethod = "byNodeName"; break; case 4: $pasteMethod = "byCharacterMap"; break; } string $timeMethod = "clipboard"; $whichMethod = `optionVar -q pasteClipTimeMethod`; switch ($whichMethod) { case 1: $timeMethod = "currentTime"; break; case 2: $timeMethod = "timeline"; break; case 3: $timeMethod = "clipboard"; break; } // doPasteClipArgList takes a string array // $cmd = "doPasteClipArgList 2 { " + "\"" + $pasteMethod + "\"" + ",\"" + $timeMethod + "\"" + " };"; return $cmd; } // // Procedure Name: // performPasteClip // // Description: // Paste a clip 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 paste a clip 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 performPasteClip (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. // if ($cmd != "") evalEcho($cmd); break; // Show the option box. // case 1: pasteClipOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }