Hey, I'm a MEL noob, so maybe someone can help me.
I've got this script with two procedures.
One is global, and it creates the window with my fields and buttons the other one is the action that runs when you hit the apply-button.
I thought I'd make the second one local, but it doesn't work. Tried adding it before the global proc as well, but no difference. It just say error: can't find procedure "procedureName"
I've saved the script as a .mel file, sourced it, and I launch it by calling the global proc.
It works if I make both global though.... must be missing something.
Replies
I ran into this problem before myself and was told as such.
Thanks.
ah, i see. I missed the part where you said how you are running it. if that is the case, than yes, it needs to be global. there are still ways to get around it, but it's a bit silly.
***end edit***
you can certainly have them be local, if they are contained in the same script. how are you running it? for UIs, I usually use script nodes to embed them in the rig file. I've never had a problem when I've done it that way.
I'll post an example snippet here:
/////////////////////////////////////////////////////////////////////////////////////////////
proc ExampleOfLocal ()
{
polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (`window -ex ExampleGUI`) deleteUI ExampleGUI;
window
-title "ExampleGUI"
-widthHeight 150 150
ExampleGUI;
scrollLayout -horizontalScrollBarThickness 0 -verticalScrollBarThickness 1 ;
string $tabs = `tabLayout ExampleTabs`;
//declaring variables
string $ExampleImage = `internalVar -userPrefDir` + "icons/ExampleImg.jpg";
string $tab1= `columnLayout -w 150 -h 150`;
string $form = `formLayout`;
//creating the buttons
string $AnExample= `iconTextButton -style "iconOnly" -image $ExampleImage -label " " -w 50 -h 50 -command "ExampleOfLocal ;" `;
window -e -wh 150 150 ExampleGUI;
showWindow ExampleGUI;
Eg. a "global proc myProc()" declaration in "myproc.mel" (case insensitive) in any of your Maya default script locations can be run just by calling "myProc" instead of having to source it or otherwise load it first.
edit: Jeremy, how good are script nodes? Do you find them very useful for rig controls? I've never really looked into using them, so I don't really understand all that much, I guess you can just tell them to be executed when the file is opened/closed/saved? In that case if you have a whole UI in script node form, do you need to call commands to destroy it on file close etc.?
Also, I hope you don't comment your real files like that
I love script nodes. usually, for rig UIs, I dump all of the code into a new script node, and at the very end, after showWindow exampleWindow;
I just throw a call to the global proc for the UI
exampleUI;
then there are options in the script node for setting it to open on file open(what I usually choose) or open on demand.(like calling the global proc in the command line)
this method is also much nicer for animators who refuse to copy over your scripts or put them in the wrong place. there is nothing to copy here(except UI images if you have any)
hope that helps. I can whip up a more clear explanation/mini tut if need be
cheers