+ Chapter - 09 - MEL - MEL Script Nodes +
Instructor - Pradeep Mamgain
+ Overview +
MEL allows scripters to save maya scripts inside of Maya file. In this chapter we will create and explore MEL script nodes. You can execute script's payload in response to various events like, opening/closing of the file, GUI open/close, UI configuration (internal), Scene Configuratin (Internal) or time changed event.
EXECUTE OPTIONS and EVENTS ASSOCIATED WITH IT
GUI Open/Close
Before - When you open the Maya scene.
After - When you de-reference the Maya file or delete node.
Open / Close
Before - When you open the scene in Batch Mode.
After - When you close or de-reference file in Batch Mode or delete node.
Software Render
Before - Before an Animation is rendered.
After - After on Animation is rendered.
Software Frame Render
Before - Before each Animation is rendered.
After - After each Animation is rendered.
Demand
You specifically call it with scriptNode command.
+ Creating / Editing / Deleting Script Node +
We will create a Script Node "test" and save a message in it. It will be executed and displayed when someone opens the file. Open file ch09_mel_script_node.ma. Go to Window > Animation Editor > Expression Editor. Expression editor window will pop-up. From editor's menu click on Select Filter > By Script Node Name. Any existing script nodes will be displayed there. In Script Node Name text box type name as test. In script text box type following MEL command.
headsUpMessage "Diffuse pass render completed, please check it";
Click on Create button. Your editor window will look like, as seen in Figure - 9.1.

Figure - 9.1 - Expression Editor.
From Execute On drop down, select Open/Close. Click on the Edit button to accept the changes. Highlight the code in Script text box and click on the Test Script button. You should see a message in the scene window in Maya Interface as seen in Figure - 9.2.

Figure - 9.2 - headsUpMessage, displayed in Maya scene.
Save the file and re-open it, you should see message again. It is a nice way to convey message to your team members. To edit the script, open the script editor, from editor's menu click on Select Filter > By Script Node Name.From the Script Node list, select the node you want to edit and edit the script in the Script box. Click on Edit button to accept the changes. If you need to undo the changes click on the reload button. To delete, click on the Delete button.
If you want to prevent script nodes from executing, when you open the file. Go to File > Open Scene > Option Box
+ What Next ? +
Now we have understanding of Script Nodes, in next chapter we will learn how to execute OS commands; using MEL system command.
+ Download Project +
Dear guest, Only registered members can download projects/footages/scripts and Video files.Kindly get registered to download the files. It will also help us in informing you that when new tutorial/article/resource or cg news is available. Once you get registered downlaod link will appear here. - Downloaded times.
+ Save / Promote This Article/Tutorial/Information +
If you enjoyed this article your vote is always highly appreciated.+ Other Info +
+ Discuss in Forums