Drag & drop a Maya MEL file into Maya and the contents of the MEL file will be executed. Is there a way to get the absolute path of the file when dragging and dropping?
Hopefully this can get you started
test.mel:
global proc FindMe() {}
print("whatIs result -> " + `whatIs "FindMe"`);
Drag-dropping the file into Maya produces the following output:
> source "C:/Users/itypewithmyhands/Desktop/test.mel";
> whatIs result -> Mel procedure found in: C:/Users/itypewithmyhands/Desktop/test.mel
Interesting points to note:
source <file>
statement, which means you'll have to do some internal magic unknown to me in order to know if the file was actually dropped, or simply sourcedproc
you search for has to be marked globalYou need to regex (or similar) the result of the whatIs
command to get the path you're after. Something like .*found in: (.+?\.mel)
seems to work well enough. Example