A Maya ASCII (.ma) file is a script of MEL commands that rebuilds the
scene when run. Autodesk’s Maya help describes how such files are organised (“Organization
of Maya ASCII files”); this page follows it. The sections must come in this order for
the file to load, and only the commands listed are supported: other MEL in the file is
not saved back as written.
Header
Comments run from // to the end of the line and are ignored, except
that the first six characters of the file must be //Maya. Maya writes
lines such as:
//Maya ASCII 2024 scene
//Name: solstice.ma
//Last modified: Sun, Dec 21, 97 10:18:26 AM
Sections
| Section | Commands | Purpose |
|---|---|---|
| file references | file -r -rpr prefix fileName;, file -r -ns namespace fileName;, with -dr to defer loading | other Maya files referenced into the scene |
| requirements | requires productName version;, such as requires maya "2024"; | the Maya version and plug-ins needed |
| units | currentUnit -l cm -a deg -t ntsc; | the linear, angular and time units in which the numbers below are written |
| file information | fileInfo "name" "value"; | Maya writes five: application, product, version, cutIdentifier and osv; others are kept |
| nodes, attributes and parenting | createNode type -n name [-p parent] [-s];, setAttr attribute [-type typeName] value;, addAttr, select, parent child parent;, parent -add, parent -w -add | the scene’s nodes and their values; select picks nodes from referenced files before changing them; parent -add makes instances |
| script nodes | script nodes | MEL to run when the file opens or closes, or the node is deleted; their order is not guaranteed |
| disconnections | disconnectAttr source destination; | in files with references, connections between referenced nodes to break |
| connections | connectAttr source destination; | the connections of the dependency graph |
Nodes and attributes
Each node is created once, then its attributes are set; attribute names may be the
long or the short form, written after a dot (pCubeShape1.i is the
mesh’s inMesh). Values with a type other than a number carry
-type, such as "string", "double3",
"matrix" or "mesh", and array attributes take an index
range and a size, as in setAttr -s 8 ".vt[0:7]" …. Node types and their
attributes are those of Maya’s node reference; the file format itself does not list
them.
Example
//Maya ASCII 2024 scene
requires maya "2024";
currentUnit -l centimeter -a degree -t film;
fileInfo "application" "maya";
createNode transform -n "pCube1";
setAttr ".t" -type "double3" 0 1 0 ;
createNode mesh -n "pCubeShape1" -p "pCube1";
createNode polyCube -n "polyCube1";
connectAttr "polyCube1.out" "pCubeShape1.i";
createNode act on that node, so
.t means pCube1.translate.