PDA

View Full Version : auto-sourcing problem from script/path


atzfratz
10-27-2004, 03:43 PM
Hi, i have a little problem here. I have created a custom Menu in the Main Menu bar which executes a script that is lying in a script path. the main global procedure in this script is called like the name of the mel file. in fact maya finds that global procedure BUT not the local procs inside. i have different menuitems which all call the same global procedure just with a different argument. like "scriptname (0)" is one menuitem and "scriptname (1)" is another. scriptname is the gloabl procedure in the fille, but i get an error message as soon as a local procedure is used inside the "global proc scriptname " saying that maya couldn`t find it. Do i have to save every single procedure in an single mel file, or make all procedures global. I thought i just need an global procedure to enter the mel file, and all local procedures were found then?

mhovland
10-27-2004, 03:57 PM
Make sure that all local procedures come before the global procedures in the file. I have found that locals need to be before the globals that are calling them. Not sure why, maybe someone like Mark Wilkins can explain this behavior?

mrgoodbyte
10-27-2004, 04:32 PM
When you call a procedure Maya will go through it's script paths sequentially. When a mel file is found with the same name as the procedure it will assume it's in there. Maya will terminate it's search as soon as it finds the procedure it's looking for. So if that is at the start of the mel file, the script is only half-sourced. If you would put the global at the end of the script Maya will read and source the whole script up until the global procedure, which happens to be the last procedure in the script.
To completely failsafe your script, source the complete script as first call in the script. This will ensure all procedures in the script are available.

-Ronald

atzfratz
10-27-2004, 04:52 PM
thx guys, putting the global procedure at the end tottaly did the job for me.


and thx for the explaination :)

EDIT: Oh no, actually now only one button more works, i have placed my global procedure at the bottom and even sourced the script in the first line of that procedure, but still it cant execute most of the commands. Maybe the problem is, that the local procedures themselves use other local procedures. I thought as long its all in the same file there should be no problem!? any more suggestions?

mhovland
10-27-2004, 07:30 PM
Since you said that only one button works, I assume the local procs are being called by button presses? If that is the case, all procedures that are called by buttons need to be global.

atzfratz
10-28-2004, 12:04 PM
no, my buttons all call the same gloab procedure, just with a different argument.
this global procedure calls the main procedures for doing different things. and in those main procedures there are other local procedures used like to get shaders from a shape node and such stuff. But those last procedures were not found. its a little bit like that.

proc miniprocedure1 ()

proc miniprocedure2 ()

proc mainprocedure1 () {
miniprocedure1;
};

proc mainprocedure2 () {
miniprocedure2;
};

global proc superMainProcedure (int $i) {
if ($i = 1) {
mainprocedure1;
} else if ($i = 2) {
mainprocedure2;
};
};

anyone sees a probem in this, the script is then called from a custom menu always with superMainProcedure (1) or (2) and then the script editor says miniprocedure1 not found.
actually the buttons working now, are those that dont use a miniprocedure.
any ideas?

mhovland
10-28-2004, 12:34 PM
I would have to see the actual code to give you any input of value. It sounds like a pretty big bug hunt :)

atzfratz
10-28-2004, 05:08 PM
please check your pm mike.

CGTalk Moderation
01-19-2006, 06:00 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.