File Format¶
What is known of Maya scene files, learned from files Maya writes: fixtures
saved by Maya 2018, 2022 and 2024 (samples/models/), each scene saved as
both .mb and .ma, and a read-only sweep of 4076 production files (771
.mb, 3305 .ma). "Observed" marks rules seen in every file so far but not
yet probed further.
Maya Binary (.mb)¶
Container¶
.mb is an IFF variant, 64-bit flavour (FOR8) for every Maya 2018 to 2025
file. Values are big-endian.
| Part | Bytes | Notes |
|---|---|---|
| tag | 4 | FOR8, LIS8, CAT8, PRO8 for groups, any 4 bytes for data |
| reserved | 4 | Not initialised by Maya and ignored on read (zeroed copies open in Maya 2024) |
| size | 8 | u64. Excludes the header and any padding |
| form type | 4 | Groups only: the first 4 bytes of the body |
- Data chunks are padded with NUL bytes to a multiple of 8, counted from the start of their data. Children of a group start right after its form type, so chunk starts are usually not 8-byte aligned in the file.
- Groups are never padded: their size is always 4 + the extents of their children.
Layout¶
FOR8 Maya
FOR8 HEAD header
FOR8 FRDI one per reference (file -rdi)
FOR8 FREF one per reference (file -r)
FOR8 <type id> one per created node
FOR8 SLCT one per default node with edited attributes (select -ne)
FOR8 PING one per extra parent of an instanced node (parent -add)
LIS8 CONS
FOR8 CONN connections and relationships
FOR8 HEAD trailer
Header (HEAD)¶
| Chunk | Content | .ma twin |
|---|---|---|
VERS |
Maya version (2022, 2018ff09 for Maya 2019) |
requires maya |
UVER, MADE, ICON, INFO |
Strings, undef so far |
|
CHNG |
Save date | //Last modified: |
OBJN, INCL |
Object count, reference paths | |
LUNI, TUNI, AUNI |
Linear, time and angle units | currentUnit |
TDUR |
141120000 (ticks per second) | |
FINF |
key\0value\0 |
fileInfo |
PLUG |
plugin\0version\0requires flags\0 then repeated nodeTypeName\0 + 4-byte type id |
requires |
PLUG maps plugin node type ids to names, so plugin nodes can be named without
the plugin. Two production type ids (0x58000300, 0x58000301) are not
listed by any PLUG chunk of their files.
References¶
FRDI(file -rdi): one per reference at every depth, the references of referenced files included. A u32 depth (1 for this file's own references), thenpath\0namespace\0, a flag byte (1 so far), a deferred flag (1 for-dr 1),refNode\0, padding, the-opoptions string, the file type (mayaBinary,mayaAscii).FREF(file -r): one per top-level reference, the same layout without the depth. Its deferred flag is always 1, like the-dr 1of everyfile -rline; onlyFRDItells deferred references apart.- Paths are stored unresolved: environment variables kept, and no
{n}copy number for a file referenced twice (Maya adds it on load). - The
-opstring caches the referenced file's own header, itsINCLreferences included. Deferred references have none. - The trailer
INCLlists the top-level reference paths, inFREForder. - The reference node (
REFNgroup) holds aREFEchunk (itsedattribute): the reference edits, see below.
Reference edits (REFE)¶
The value (after ed\0 and the flag byte) is the owning reference node name,
then two sections with the same layout: a u32 group count, and per group a
reference node name, a u32 edit count and the edits. Fixtures always leave the
first section's groups empty; production files sometimes put parent edits
there. Each edit is a u32 kind and NUL-terminated strings, as in the
dataReferenceEdits lines of .ma files:
| Kind | .ma command |
Strings |
|---|---|---|
| 0 | parent |
node, new parent, flags (-s -r) |
| 1 | addAttr |
node, long name, short name, arguments |
| 2 | setAttr |
node, attribute, MEL arguments (-type "string" "P:/a.exr") |
| 3 | disconnectAttr |
source plug, destination plug, flags (-na) |
| 4 | deleteAttr |
node, attribute, flags |
| 5 | connectAttr |
u32 side, then: side 3 or 4 (the referenced plug is the source or the destination): reference node, plug, placeholder, extra; side 0 (both ends referenced): reference node, source, destination, two placeholders, extra |
| 8 | lock attribute | node, attribute |
| 9 | unlock attribute | node, attribute |
Attribute names in edits are long names. Nodes are full DAG paths, which
include the local nodes a referenced node was parented under
(|localGrp|e:refCube). A connection between a local node and a referenced
node is stored twice: as a plain CWFL to the reference node's placeholder
list (aRN.phl[1]) and as a kind 5 edit mapping the placeholder to the
referenced plug. Parenting a local node under a referenced one creates a local
<refNode>fosterParent1 node and a kind 0 edit. Locking a node is not an
edit. All 786 production .mb files decode with these rules and re-encode
byte for byte (260k edits).
Nodes¶
Each node is a group whose form type is the node's 4-byte type id: readable
tags for built-in types (XFRM transform, DMSH mesh, RTFT file, AUDI
audio, REFN reference, SCRP script), raw ids for plugin types.
CREA (first chunk): flag byte, name\0, optional parent\0, 16-byte UUID.
The parent is a short name, or a DAG path (|grpA|cube) when the short name
is not unique. Flag bits: 0x04 DAG node and 0x08 transform (checked on
48k nodes of fixtures and production files against the type hierarchy);
observed: 0x80 no parent, 0x01 shared (-s), 0x10 reference node.
The UUID's text form (B6A733A0-4DD6-F4D1-E1A6-3282A7CA548B) reads the 16
bytes as four little-endian u32 words.
Attribute chunks follow: the tag is the storage type, the data is
shortName\0 + a flag byte + the value. Tags in production: DBLE, DBL2,
DBL3, DBL#, FLT2, FLT3, FLT#, I32#, LNG3, STR, STR#,
MATR, CMPD, CMP#, FLGS, MESH, NRBC, NRBS, PNT#, VEC#, ATTR
(added attribute), ATAL (attribute alias). DBLE also stores booleans,
integers, enums and times (as int64 ticks), so decoding a value needs the
attribute's type.
Instances¶
A root FOR8 PING group holds one PRNT chunk per extra parent (parent
-add in .ma): a flag byte, the instanced node's absolute path, then the
extra parent (\x02|hero|heroShape\0heroInstance\0). An instanced node, and
every node below it, then has one DAG path per parent; connections name each
instance by its full path (|copies|heroInstance|heroShape.iog), never by
the short name, even when no other node shares it. No production .mb uses
instancing; 2774 parent -add statements appear in production .ma files.
Selections and connections¶
SLCTgroup: aSLCTchunk with the node name (:time1, no NUL), then attribute chunks, likeselect -nefollowed bysetAttrin.ma.CWFL: flag byte (0x01=-na),source plug\0destination plug\0. Plugs use the shortest unique node name:grpA.tx,|grpB|cube.r,ns:target.t.RELA:kind\0node\0, u32 count, then that many plugs.
Trailer (HEAD)¶
OBJN, INCL, then DATS + SMTD (metadata, see below) and BCSZ, whose
u32 is the distance in bytes from the start of the trailer group to the BCSZ
chunk; BCSZ ends the file. Resizing INCL or SMTD changes that distance;
whether Maya reads it is not probed yet.
How nodes are named¶
Measured by renaming nodes in Maya and saving:
CREAparents,CWFLandRELAname a node by its short name when no other node of the file has it, else by its absolute DAG path, never a partial path: with|root|a|b|leafand|root|c|b|leafthe file stores|root|a|b|leaf.tx, thougha|b|leafwould be unique. (Maya's commands show the shortest unique partial path,x|b|leaf.translateX; the file does not.) After a rename Maya re-derives this for every node involved: a name that becomes ambiguous turns into a path, one that becomes unique turns back into a short name.- Reference edits and the
externalContentTablealways name DAG nodes by absolute path, other nodes by name. - Default nodes keep the root namespace prefix (
:initialShadingGroup). cmds.renameon a transform also renames its direct shape children whose name starts with the old name, by replacing that prefix (boxShape,boxShape1,boxShapeOrig, evenboxer), namespace included (ns:boxShape>otherShape). It leavesmyboxShape, child transforms and deeper nodes alone. Renaming a shape renames nothing else.- Expressions store direct attribute references compiled (
.O[0] = time * 2;, the names live in the connections); names inside MEL commands (getAttr box.ty) stay as text, and Maya does not update them on rename. Neither does it update string attributes holding a node name.
externalContentTable¶
The trailer DATS declares the columns (node, key, upath, upathcrc,
rpath, roles); SMTD is \0raw\0, the metadata text, \0. The text is
the same in .ma (dataStructure + applyMetadata -fmt "raw" -v "..."):
a channel, a stream, then per row an index line and a values line,
"node" "fileTextureName" "P:/a.exr" 2550333794 "" "sourceImages".
node: absolute DAG path or name; a reference's row names its reference node, with an empty key and roleFileRef.upathcrc: zlib CRC-32 of the path in the system code page (1252 here), even in.mb, whose text is UTF-8.rpath: the resolved path when the file exists, else empty.- Maya rewrites the rows when a node is renamed or a path changes, and accepts a stale table on open.
Maya ASCII (.ma)¶
A MEL script, in the code page named by its //Codeset: comment (1252 for
every production file), with LF or CRLF line endings (CRLF in 1005 of the
3301 non-empty production files, Maya 2016 to 2022). Statements in order:
file -rdi / file -r per reference, requires, currentUnit, fileInfo,
then createNode blocks, select -ne blocks for default nodes,
connectAttr / relationship / parent -add (instances), and an optional
dataStructure + applyMetadata pair, then a // End of comment. Some
production files lack the header comments, and some are empty. 3300 of the
3305 production .ma files split into ;-terminated statements and join back
byte for byte; the other 5 hold .mb chunks partway through.
- A node is
createNode <type> [-s] -n "name" [-p "parent"], followed by its own statements:rename -uid "<UUID>",setAttr,addAttr,lockNode. The parent is named like in.mb(short name, else absolute path). setAttr ".attr" [-type "<type>"] values: the attribute is the first string; strings use-type "string", string arrays-type "stringArray"with a count, reference edits-type "dataReferenceEdits".- References:
file -rdi <depth> -ns "ns" [-dr 1] -rfn "RN" [-op "..."] -typ "<type>" "path"at every depth, andfile -rfor the top level.-typmust match the file: a.mapath with-typ "mayaBinary"loads nothing, silently (the reference still reports loaded). The same holds for the file type string of.mbFRDI/FREF. dataReferenceEdits: the owner, then every group of both sections in one list ("node" countand the edits), with no section counts. The first section ends with the owner's own group (all fixtures and production files). Edit arguments are MEL inside a MEL string, so escaped twice. Maya 2018 to 2022 write the node of an addAttr edit as a bare word (1 |grp|ns:node "note" "note" ...).- Long string literals are split into MEL concatenations across lines:
"part"then+ "part"on the next line, and inside reference edits within parentheses,("part" + "part"). A reader must join them; a single long literal is just as valid when writing. parent -s -nc -r -add "child" "parent"(also spelled with long flags,-shape -noConnections -relative -addObject) adds a parent: instancing.applyMetadata -fmt "raw" -v "<text>"holds the externalContentTable text.- Maya writes short flags, but 8 production files, written by scripts, use
long ones throughout (
createNode transform -name "ALL" -parent "rig",rename -uuid,select -noExpand,connectAttr -nextAvailable). A reader must accept both spellings of every flag it reads. No production file putscreateNodeflags before the type or spellssetAttr -typeshort. - Opening a
.ma, Maya keeps its own node (and UUID) for the nodes every scene starts with (lightLinker1,layerManager,renderLayerManager), though the file stores a UUID for them.
Shared traps¶
- Text encoding:
.mbtext is UTF-8 (STRvalues, metadata);.matext uses the code page of its//Codeset:comment. TheexternalContentTableCRC is computed on the code page bytes in both. externalContentTablelists some file dependencies, but only in about 69% of production.mband 21% of.ma, and never Alembic or Arnold nodes.- Maya-native path attributes use forward slashes; plugin attributes store
what they were given (production Yeti
cfnvalues use backslashes).