Procedure In A Script File With The Same Name

Hello,

If I put a procedure foo() in a script named foo.mel, what will be evaluated when I'll call foo ?

The script from its beginning, or the procedure ?

Thanks.

the name of the file is irrelevant (unless you have it in your maya\7.0\scripts folder. (then I guess the main proc in only prepared for load if the file is called like the proc (i don't really know)))

To source the complete mel-file you have to run:
CODE
source "foo.mel";
CODE
foo;
just runs a proc or command thats called "foo";

QUOTE(ewerybody @ 11/16/06, 11:52 AM) [snapback]252571[/snapback]
the name of the file is irrelevant (unless you have it in your maya\7.0\scripts folder. (then I guess the main proc in only prepared for load if the file is called like the proc (i don't really know)))
Actually, it is in this script folder. :slight_smile:

I am studying a script from Maya : scripts\others\relationshipEditor.mel
It is about 10000 lines long.

At the very beginning, there is this piece of code :
CODE
if (!selectionConnection -exists setList)
    selectionConnection    -setList setList;

if (!scriptedPanelType -exists relationshipPanel)
{
    //  Define the callbacks for the relationship panel.
    scriptedPanelType
        (...)              // some callbacks reference
}

All the remaning code is in procedures, and among them, there is one with the same name than the script's one.

I wonder what I should trace in first : the code at the beginning, or the procedure which has the same name than the script.

when a procedure has the same name as the file, then maya will source the file automatically as soon as you use the procedure. It does not matter where in the file the procedure is located. Since the entire file gets loaded, every other procedure inside that file will then be available for maya to later use. If there is code in the file which is not in a procedure, then it will be executed as soon as the file gets sourced, which is just before the procedure which caused the file to become sourced gets executed.

OK. It is now clear : initial piece of code in first, and next relationshipEditor().

Thanks a lot !

right, you can also put print statements in that file and restart maya, once you have figured out what happens, then you can remove them again.

Or, you can make a copy of that file, then place that copy in your Documents And Settings/user/maya.../scripts folder and modify the file. when maya starts it will use that file instead of the original one, when you delete it, it will use the original again.

Thanks. I didn't think about the second possibility.