decrezero
06-12-2007, 04:16 AM
I figured out you can hack together file scoped local constant by declaring them:
proc type name() { return assignment; };
// within the file ('name' == assignment)
// and assignment is of type
I figured this type of thinking might let me call a local function as a UI command, but I can't think how. I know that technically I'm abusing some of the properties of MEL, and the code won't look right.
A simple example of what I'm talking about:
Important Note: If this script, or the above script, is not loaded from a script directory then the localFunction will be declared as a global proc and the example will not be valid.
example1.mel:
proc string localFunction()
{
print "this is a local function\n";
return ""; // keeps the -c flag from sending an error
}
global proc example1()
{
window -t "test window" someWindow;
menuBarLayout;
menu -l "test";
menuItem
-l "Restore Defaults"
-c `localFunction`; // executes on window creation not when the button is clicked
showWindow someWindow;
}
I could easily just define the UI procedures as global and be done with it, but I'm concerned about namespace safety with the number of global procedures that are being defined. (and it would lower maya's general use memory footprint)
proc type name() { return assignment; };
// within the file ('name' == assignment)
// and assignment is of type
I figured this type of thinking might let me call a local function as a UI command, but I can't think how. I know that technically I'm abusing some of the properties of MEL, and the code won't look right.
A simple example of what I'm talking about:
Important Note: If this script, or the above script, is not loaded from a script directory then the localFunction will be declared as a global proc and the example will not be valid.
example1.mel:
proc string localFunction()
{
print "this is a local function\n";
return ""; // keeps the -c flag from sending an error
}
global proc example1()
{
window -t "test window" someWindow;
menuBarLayout;
menu -l "test";
menuItem
-l "Restore Defaults"
-c `localFunction`; // executes on window creation not when the button is clicked
showWindow someWindow;
}
I could easily just define the UI procedures as global and be done with it, but I'm concerned about namespace safety with the number of global procedures that are being defined. (and it would lower maya's general use memory footprint)
