// Copyright (C) 1997-2004 Alias Systems Corp. // // The information in this file is provided for the exclusive use of the // licensees of Alias. Such users have the right to use, modify, // and incorporate this code into other products for purposes authorized // by the Alias license agreement, without fee. // // ALIAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO // EVENT SHALL ALIAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. global proc pasteScene(){ string $fileExt = ".mb"; if (`about -evalVersion`) { $fileExt = ".mp"; } // determine temp directory string $tmpFile = "/maya_sceneClipBoard" + $fileExt; string $tmpdir = `getenv TMPDIR`; string $filePath = ($tmpdir + $tmpFile); // find list of existing transforms for comparison after import string $existingTransforms[] = `ls -transforms`; // import scene file -force -import -renameAll true -renamingPrefix "pasted_" -groupReference $filePath; // determine what the new nodes are so they may be selected string $allTransforms[] = `ls -transforms`; string $newTransforms[] = stringArrayRemove( $existingTransforms, $allTransforms); select -replace $newTransforms; select -replace `ls -sl -head 1`; } global proc cutCopyScene (int $cut){ string $fileExt = ".mb"; string $fileType = "mayaBinary"; if (`about -evalVersion`) { $fileExt = ".mp"; $fileType = "mayaPLE"; } // determine temp directory string $tmpFile = "/maya_sceneClipBoard" + $fileExt; string $tmpdir = `getenv TMPDIR`; string $filePath = ($tmpdir + $tmpFile); // export selected nodes file -force -exportSelected -constructionHistory true -channels true -expressions true -constraints true -shader true -type $fileType $filePath; // delete nodes if user asks for cut if ($cut){ delete; } } global proc cutCopyPaste (string $operation){ // $operation: cut // copy // paste // make sure generateChannelMenu has been sourced so channelBox commands work if (!`exists channelBoxCommand`){ source generateChannelMenu.mel; } // based on active panel, channelBox selection and selected nodes // determine what user wants to cut copy paste string $option = "none";; string $parameter; string $selection[] = `ls -sl`; // determine if active panel is animation based // this value should override the channelBox cut copy paste string $currentPanel = `getPanel -underPointer`; if( $currentPanel == "" ) { $currentPanel = `getPanel -withFocus`; } string $panelType = `getPanel -typeOf $currentPanel`; if( $panelType == "scriptedPanel" ) { $panelType = `scriptedPanel -q -type $currentPanel`; if ($panelType == "graphEditor" || $panelType == "dopeSheetPanel" || $panelType == "clipEditorPanel") { $option = $panelType; if( $panelType == "dopeSheetPanel" ) { $parameter = $currentPanel + "OutlinerSelection"; } else { $parameter = editorNameFromPanel( $currentPanel ); } } else { $option = "nodes"; } } // determine if anything is selected else if (size($selection)){ $option = "nodes"; // determine if attrs are selected in channelBox string $attrList[] = `channelBox -q -selectedMainAttributes mainChannelBox`; string $attrHistoryList[] = `channelBox -q -selectedHistoryAttributes mainChannelBox`; string $attrOutputList[] = `channelBox -q -selectedOutputAttributes mainChannelBox`; string $attrShapeList[] = `channelBox -q -selectedShapeAttributes mainChannelBox`; if ((size($attrList) != 0) || (size($attrHistoryList) != 0) || (size($attrOutputList) != 0) || (size($attrOutputList) != 0)){ $option = "channels"; } } else if (!size($selection) && $operation == "paste"){ $option = "nodes"; } switch ($option){ case "channels": if ($operation == "cut"){ channelBoxCommand -cut; } else if ($operation == "copy"){ channelBoxCommand -copy; } else { channelBoxCommand -paste; } break; case "graphEditor": if ($operation == "cut"){ performCutKeyArgList 1 {"3", $parameter, "1"}; } else if ($operation == "copy"){ performCopyKeyArgList 1 {"3", $parameter, "1"}; } else { performPasteKeyArgList 1 {"3", $parameter, "1"}; } break; case "dopeSheetPanel": if ($operation == "cut"){ performCutKeyArgList 1 {"0", $parameter, "2"}; } else if ($operation == "copy"){ performCopyKeyArgList 1 {"0", $parameter, "2"}; } else { performPasteKeyArgList 1 {"0", $parameter, "2"}; } break; case "clipEditorPanel": if ($operation == "cut"){ doCutClipArgList 1 { $parameter }; } else if ($operation == "copy"){ doCopyClipArgList 1 { $parameter }; } else { performPasteClip 0; } break; case "nodes": if ($operation == "cut"){ cutCopyScene 1; } else if ($operation == "copy"){ cutCopyScene 0; } else { pasteScene; } break; case "none": // nothing selected - nothing required but a warning warning "Nothing is selected."; break; } }