PDA

View Full Version : MEL help


thebrianproject
11-23-2009, 03:53 AM
Hey everyone. I'm learning MEL scripting right now, and I have a sort of hodgepodge of knowledge with a few of gaps. I had two questions that I was hoping someone could help me out with.

1. what's the difference between a regular procedure and a global one?

2. how come sometimes when I source a script, maya will automatically run it, but sometimes I have to call a procedure inside the .mel file?

giordi
11-23-2009, 05:17 PM
that s a good question i know some of MEL but i dunno the answer for this question , i hope somebody will answer

mlefevre
11-23-2009, 08:34 PM
A global procedure within a script, once sourced, can be called by other scripts.

For example, lets say you have a script called makeSphere.mel, and inside there you have a global procedure called makeSphere(), which, makes a sphere!
If you have another script named makeCube.mel, it can execute makeSphere() within it.


If you source a script, and it runs, then perhaps it'll have a call to procedure at some point in the .mel file.

For instance, if we source this script, lets call it printer.mel:

global proc printer(string $name){

print("Hello " + $name + "\n");

}

nothing will happen, until we make a call to it, like:

printer("Matt");
Hello Matt

However, if we modify the script like so:

global proc printer(string $name){

print("Hello " + $name + "\n");

}

printer("Matt");


..the procedure will be executed when we source it, because within the script, we've made a call to the procedure as well as declaring it.

thebrianproject
11-23-2009, 09:05 PM
Awesome. Thanks for taking the time to explain mlefevre, that's a basic part of mel that has been fuzzy for me for quite some time.

CGTalk Moderation
11-23-2009, 09:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.