Write file translators
 
 
 

To the Maya ASCII format

If you are writing a program to translate other kinds of files to Maya ASCII file format, the work is fairly straightforward. The bulk of what you need to do is find Maya node and attribute equivalences to the foreign data types. For this you will probably want to construct your own sample Maya files and refer to the document called Node and Attribute Reference.

Notes:

From the Maya ASCII format

If you want to write a program to translate Maya ASCII files to other file formats, you have a difficult job ahead of you. To do the job properly, you would not only need to be able to read in the files, but also to read in the referenced files. Since MEL references can contain any arbitrary MEL code, you would either have to not support them, or write a full MEL interpreter.

An easier way to solve this problem is provided in the Maya Developer’s Tool Kit. There you will find an example of a file translator plug-in under the MPxFileTranslator class (. Using the documentation there, and the example (called lepTranslator) as a basis, you can write a plug-in that will allow Maya to save files in the format you prefer.

It is also possible to write data out through MEL. Though this method is probably not appropriate for comprehensive, large-scale translators, it can be a quick and easy way to export relatively small and simple sets of ASCII data. Provided all of the data required is accessible through MEL, you can use the fopen, fprint, and fclose commands to write the data to a file.