Skip to content

Instantly share code, notes, and snippets.

@Nat3Turner
Forked from Meatplowz/performFileDropAction.mel
Last active June 28, 2023 14:18
Show Gist options
  • Select an option

  • Save Nat3Turner/b5029d9649b742f3cd34a24e5f94abf3 to your computer and use it in GitHub Desktop.

Select an option

Save Nat3Turner/b5029d9649b742f3cd34a24e5f94abf3 to your computer and use it in GitHub Desktop.
Override the Maya Drag and Drop Behavior for File Open/Import
// Copyright (C) 1997-2014 Autodesk, Inc., and/or its licensors.
// All rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors,
// which is protected by U.S. and Canadian federal copyright law and by
// international treaties.
//
// The Data is provided for use exclusively by You. You have the right to use,
// modify, and incorporate this Data into other products for purposes authorized
// by the Autodesk software license agreement, without fee.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK
// DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES
// INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT,
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE
// OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS
// LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL,
// DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS
// LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
//
//
// Creation Date: June 25, 2012
//
// Description:
// performFileDropAction, helper function to import dropped files
//
//
// Randall Hess randall.hess@gmail.com
// Instructions: Copy this file over your local maya version to override the default behavior
// Additional: You can also build and load this as a module and not overwrite the local maya file.
// Location: C:\Program Files\Autodesk\MayaXX\scripts\others
global proc int
performFileDropAction (string $theFile)
{
string $msg = "Would you like to Import, Open or Reference the file?";
string $import = "Import";
string $open = "Open";
string $reference = "Reference";
string $cancel = "Cancel";
string $response = `confirmDialog -message $msg -button $import -button $open -button $reference -button $cancel -defaultButton $cancel`;
if ($response == $cancel)
{
return(1);
}
else if ($response == $open)
{
global string $gv_operationMode;
string $save_gv_operationMode = $gv_operationMode;
$gv_operationMode = "Open";
int $result = performFileAction ($theFile, 1, "");
$gv_operationMode = $save_gv_operationMode;
return ($result);
}
else if ($response == $import)
{
file -import -namespace (basenameEx($theFile)) $theFile ;
return(1);
}
else if ($response == $reference)
{
file -reference -namespace (basenameEx($theFile)) $theFile ;
return(1);
}
}
@Nat3Turner
Copy link
Copy Markdown
Author

Hey Randall, long time! I was using this script and noticed the Open call wasn't opening. I dug into the other MEL file and noticed they'd changed the global variable to just be gOperationMode.

@Meatplowz
Copy link
Copy Markdown

Hey man, nicely done! Good assist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment