PDA

View Full Version : installing script, proc not found


McMaster
06-15-2003, 08:04 PM
Hi!
I tried to put my written script into a .mel-File and save it in script-path, but Maya only finds the Main-proc, not the others! What can I do?
Lets say, mel-file´s name is: mainproc.mel
It contains:
_________________________
proc proc1()
proc proc2()
...
global proc mainproc()
{
proc1;
proc2;
...
}
__________________________
But when I start it with mainproc in Command Line it starts, but then I get the error:
Cannot find procedure "proc1"

gmask
06-15-2003, 08:35 PM
you could make them all global procs

McMaster
06-15-2003, 11:56 PM
Isn`t there another way, because coming from object-orientated programming, one shouldn`t make anything global at all! (Information-hiding and stuff)

gmask
06-16-2003, 01:16 AM
Originally posted by McMaster

proc proc1()
proc proc2()
...
global proc mainproc()
{
proc1;
proc2;
...
}


Okay I'm gonna shoot from the hip... maybe your calls to those local procs needs to look like this?

proc1();
proc2();

Technically yes it would be better behaviour to not use too many global procs or variables.. the main concern is to not have naming conflicts though.. it's cleaner and more polite to use locel procs and variables. But there is allways more than one way to do something and if useing more globals solves it for you now you can figure out the proper way later.

McMaster
06-16-2003, 08:35 AM
OK, maybe I wasn`t precise enough, I`ve got procs where I have to pass variables to, so I`ve got the brackets anyway in the call:
proc($variable1);
But it still doesn`t work. I mean, I could put each proc in its own file, but oh no, then I would have to make it global anyway, but sorry, I think this doesn`t really make sense in Maya!
Well, seems that I have to make it the global way though, but is that the way everyone of you does it?

mark_wilkins
06-16-2003, 10:16 AM
I think something else is wrong here beyond what you're telling us about. I made a file in my script path called testing.mel that contained the following:


proc test1() {
print ("test1\n");
}

proc test2() {
print ("test2\n");
}

global proc testing() {
print "testing...\n";
test1; //Note, the () are optional
test2;
}


Anyway, it worked fine to type

testing

at the command line.

I tried a bunch of ways to screw it up, and about the only thing that didn't work was to put the global proc at the beginning rather than the end of the file. The procedures that the global proc calls must be defined earlier in the file for everything to work properly.

-- Mark

gmask
06-16-2003, 06:36 PM
Originally posted by mark_wilkins

I tried a bunch of ways to screw it up, and about the only thing that didn't work was to put the global proc at the beginning rather than the end of the file. The procedures that the global proc calls must be defined earlier in the file for everything to work properly.


That's what I was thinking?

Here's another wild shot inthe dark.. try giving those procs different names..maybe there is some sort of screwy name thing going on??

McMaster
06-17-2003, 09:08 AM
Funny, Marc`s little testingproc works for me aswell!
But my proc only works when I put global in front of everything!

Its quite a bunch, but now I`ll post it anyway, maybe someone can try! I post it without the global in front!

mattwood
06-20-2003, 02:36 PM
Mark Wilkins was right - you weren't telling us everything!

You're calling those procedures from command buttons, not from the main flow of the script, so they need to be global procs or reside within their own MEL file. I'm not sure of the exact rules on all that though, but I'm sure an expert will be along soon...

mark_wilkins
06-20-2003, 02:40 PM
Yes, commands called by buttons must be global.

-- Mark

McMaster
06-20-2003, 02:46 PM
Oh, OK, thanks for that answer. Didn`t no that! Thats a funny rule!
But thanks, knowing that it must be like that gives a much better feeling ;-)
Greets

mark_wilkins
06-20-2003, 03:07 PM
well, it kind of makes sense: the script that you attach to your button isn't actually running in the script where you define the button, it runs later when the button is pressed. So, what's local to that script isn't necessarily local to the button itself.

-- Mark

CGTalk Moderation
01-15-2006, 11:00 AM
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.