I've written a MEL script, in ScriptEditor it works fine. I would like to save this MEL script in a .mel
file for a custom Heads Up Display showing three translate parameters for selected geometry, and I want this HUD to appear in the Viewport every time Maya is loaded. I'm running Maya on Mac.
How can I do that?
headsUpDisplay -removePosition 0 1;
global proc float[] objectPosition() {
string $selectedNodes[] = `selectedNodes`;
float $position[3];
if (size($selectedNodes) > 0) {
string $mainObject = $selectedNodes[ (size($selectedNodes)-1) ];
$position[0] = `getAttr $mainObject.translateX`;
$position[1] = `getAttr $mainObject.translateY`;
$position[2] = `getAttr $mainObject.translateZ`;
} else {
$position[0] = 0;
$position[1] = 0;
$position[2] = 0;
}
return $position;
}
headsUpDisplay
-section 0
-block 1
-label "Position:"
-command "objectPosition()"
-event "SelectionChanged"
-nodeChanges "attributeChange"
BrandNewHUD;
First approach
All I have to do is to create a file named userSetup.mel
in the following directory:
I put there my MEL script. It shows my custom HUD whenever Maya starts up.
Second approach
Alternatively, I can insert my script inside initHUD.mel
located in MacOS directory:
But be careful! Make no mistakes there!