Understanding the Maya ASCII File


The Maya ASCII file format is a MEL script. It follows some very specific rules and specifications, but it is, at its core , simply a collection of a small handful of commands. While it is possible to embed further commands directly into a Maya ASCII, or .ma, file with a text editor after the fact, Maya will not save this information with the file if the file is resaved within Maya. To embed MEL commands in a Maya file, use a scriptNode .

There can be multiple reasons to open and edit a Maya ASCII file in a text editor. As Maya has evolved, many of the so-called tricks people would do, such as changing time settings without moving keyframes have been addressed by AliasWavefront in the interface. But one still popular reason to edit .ma files is to bring data into an earlier version of Maya. Moreover, occasionally a scene file will have issues, as it were. If the file is causing an artist grief , and is saved as a .ma file, it can be opened in a text editor and debugged . For this reason alone, many production facilities work exclusively with the Maya ASCII format.

Understanding the Maya ASCII format will allow you to open and edit the files in a text editor, and write software for other programs that will properly write to the Maya ASCII format. This can be as simple as a model exporter, although supporting all the geometry types that Maya supports could be challenging, to the full export of animation, lights, colors, and materials. In fact, Maya exports shading networks as Maya ASCII files.

A .ma file is split into eight distinct sections:

  • Header

  • File referencing

  • Requirements

  • Units

  • Body

  • Script nodes

  • Disconnections

  • Connections

The file must be constructed in this order.

The header information, which must begin with the six characters //Maya , details such information as how and when the file was created. Other than the first six characters, the header section is a standard Maya comment block.

The next section contains the list of file references, using the file command. This is one of the sections that often proves useful, changing references or eliminating them completely from the file. Note that not every scene uses file referencing, so this section might be empty.

Following the file references is the requirements section. This is simply a series of requires statements. At minimum, it contains a minimum version of Maya that is needed to open the file. This is where we must make our edits if we want to open a file in an earlier version. Note that this can still cause errors, if the file uses features of the newer version, and can completely be invalidated if there are nodes dependent on these new features. Note that in the past, Maya has used non-numeric version numbers . Although, due to customer complaints, this is not likely to occur again, be prepared to handle version checks based on string information, rather than numeric. Be aware, this section is also where any plug-in requirements are stated.

Next is the units section, where the currentUnit command is used to set the file s operating settings.

The body of the file is most often the lengthiest section. Consisting of a series of createNode and setAttr commands, the main body of the file creates the majority of what is in the scene file. This section can also contain the addAttr command, and the parent command, for nodes that cannot be parented upon creation.

The script node section is where script nodes, both user created and those native to Maya scenes, like the animationScriptNode , are created.

The final two sections of the Maya ASCII file disconnect and connect various attributes together. For example, if the scene contains an animated ball, the ball and the animation curves are created in the main body, and then the curves are connected to the ball in this section.




The MEL Companion
The MEL Companion: Maya Scripting for 3D Artists (Charles River Media Graphics)
ISBN: 1584502754
EAN: 2147483647
Year: 2003
Pages: 101

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net