Create Maya ASCII file without opening Maya

Hello everyone,
I’m creating a pipeline manager tool in python for maya. It is not embedded within maya as i want it to keep running even if maya crashes. I’m currently trying to build a feature to create a Maya ASCII file (basically a new scene) without opening the app. I tried just creating an empty file with a .ma extension but when i open it it is not recognised. I created an empty file myself in Maya and figured out a lot of project/file settings where embedded in the file even if it looks “empty”. I’m looking for a way to create the empty scene without having to open maya but can’t figure anything out. Have a good day! Elio

I say keep it really simple: Make a master emptyMayaFile.ma, put it someplace accessible, and just copy it to where you need it.

If you’re looking to do more than just make a placeholder file though … Well, It depends on your use-case.

But really, the easiest way to figure out what needs to go into a .ma file is to just use the text from other .ma files.

1 Like

Helpful links to some reference materials.

Maya documentation archives:
https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/16PLfHJ68c2iY6intGrBeO.html

File Formats (Maya 2011, pdf - 365Kb)

or online:

Maya ASCII file format

Translators and Exporters (Maya 2011, pdf - 330Kb)

Extended ASCII characters in node and attribute names and scene portability

Maya ASCII specific variables

Managing files for file referencing

Scenefale parser from @mottosso:

old implementation by @yamins81:

Basically, nothing complicated.
Everything will change as soon as you need to place reference links. Or you will need to place specific data blocks (Blendshapes, XGen, Alembic, Plugins/User Data, etk). Or managing interface components…
The rules for describing these entities tend to change from version to version and are often not backward compatible.

Harmony and good luck!

Thanky ou to both of you, I’ll give copying an empty maya file a try. The documentation is also really helpful!

You could generate a blank .ma file in mayapy like this:

Create a python script:

import maya.standalone
maya.standalone.initialize()
import sys
import os

import maya.cmds as cmds
cmds.file(newFile=True,prompt=False)
tmp=os.environ.get("TEMP")
cmds.file(rename=os.path.join(tmp,"temp.ma"))
cmds.file(save=True)
sys.exit()

then run in a batch file / command prompt:

mayapy C:\path_to_script\create_blank_ma.py
2 Likes