Entering Commands

 

Maya offers several ways to enter MEL commands; using the Script Editor or Command Line are the most common ways. You can also execute commands in script files, Maya ASCII (.ma) files, shelf icons, hotkeys, and expressions. Most often, however, you enter commands in the Script Editor.

 

Regardless of how you enter the commands, all MEL commands must terminate with a semicolon. The following are examples of MEL commands:

sphere -name roundy;

setAttr roundy.translateX 7;

whatIs ls;

help ls;

ls -typ nurbsSurface;

 

3ds max offers as many ways to enter MAXScript commands - it provides an arbitrary number of Script Editors based on the Windows RichEdit library, a MAXScript Listener (similar to the MEL Script Editor), and a MiniListener in the lower left corner of the UI similar to the MEL Command Line.

3ds max does not provide an ASCII scene file format, but scripts can be embedded to "live" inside the binary .MAX file format.

3ds max features so-called MacroScripts which can be used to define toolbar icons/buttons (similar to Maya's shelf icons, but icon/text button display mode can be switched by the user), menu items, Quadmenu items (similar to Maya's Hotbox).

 

Note the Differences:

·       MacroScripts are encapsulated in a context defined by the constructor MacroScript followed by the name of the ActioItem, the Category, and options like button text, tooltip, internal name, icon bitmap file and index. This is the main difference to "regular" script code.

·       Other than MEL's shelf scripts, MacroScripts can provide context-sensitive handlers to enable/disable, hide/show, check/uncheck the icon/button/menu item. Other handlers allow the execution when the icon is dropped onto a scene object or other part of the UI, and an alternative execute handler which can be used to call alternative code or provide a setup dialog. These features are used to implement context sensitive QuadMenus which show only options relevant to the current selection and/or operation, thus reducing cluttering.

·       3ds max supports two sets of icons - small (16x15) and large (24x24).

·       Text Button size is controlled by a system preference - the toolbar buttons are either sized to fit the label, or are limited to a fixed number of pixels.

 

 

MAXScript expressions do NOT have to be terminated with a semicolon, but they can be. The semicolon is supported as an expression delimiter just like in MEL and can be used to place two or more expressions in the same line, but the MAXScript parser can detect the end of an expression based on the End Of Line and the expected syntax without the need for semicolons.

(Some MEL users keep on using semicolons when switching to MAXScript.)

 

The MEL example commands would be written in MAXScript as follows:

sphere name:"roundy"

roundy.position.x = 7

classof ls

help ls

convertTo ls NURBSSurface

 

The same can be written as

sphere name:"roundy";

roundy.position.x = 7;

classof ls;

help ls;

convertTo ls NURBSSurface;

 

or as

sphere name:"roundy"; roundy.position.x = 7

classof ls; help ls; convertTo ls NURBSSurface