Managing numerous and complex MEL scripts and plug-ins can become difficult and inconsistent in production environments. The following steps will ensure that your MEL scripts get sourced and your plug-ins will get loaded without error and with consistency throughout your production environment.
2) Adding another global proc to the end of the file:
If you want to add another global proc in the SAME file and make sure that it is available just like other global procs your testProc.mel should look like this:
proc proc1()
{
print ("\n proc1");
}
proc proc2()
{
print ("\n proc2");
}
global proc testProc()
{
print ("\n testProc");
proc1;
proc2;
}
global proc testProc1()
{
print ("\n testProc1");
testProc;
proc1;
proc2;
}
If you try to call testProc1 after starting a new session of Maya, it will not be recognized. One way to fix this is to source the file. This will make all the global procs in that file available. What you do is:
# Add this line inside your userSetup.mel:
source testProc;
2a) However this defeats the purpose of having the automated system of making
available all the global procs sitting in the files that are in MAYA_SCRIPT_PATH.
So, the following will work even without the source statement in the userSetup.mel:
proc proc1()
{
print ("\n proc1");
}
proc proc2()
{
print ("\n proc2");
}
global proc testProc1()
{
print ("\n testProc1");
proc1;
proc2;
}
global proc testProc()
{
print ("\n testProc");
testProc1;
}
The above will work even without the source statement. Notice that although there are 2 global procs in the same file, testProc is still the top proc in terms of hierarchy since the flow of control goes like: testProc --> testProc1 --> proc1, proc2. Again, the order DOES MATTER.
2b) Another way of doing this would be:
proc proc1()
{
print ("\n proc1");
}
proc proc2()
{
print ("\n proc2");
}
global proc testProc2()
{
print ("\n testProc2");
testProc1;
proc1;
proc2;
}
global proc testProc1()
{
print ("\n testProc1");
proc1;
proc2;
}
global proc testProc()
{
}
Now call the testProc from inside the userSetup.mel by adding the line:
testProc;
Just calling the blank proc will make all the other global procs inside the testProc.mel available to you. But you will run into errors if you try to call the testProc1 BEFORE calling testProc.
Comments