Loading .mb/.ma outside of maya

Hey there,

i have seen various applications that are able to import/export maya both ascii and binary. Some seem to use an installed maya instance somehow. Anyone knows where i can find information on this or is able to shed some light?

I would like to import maya binary and ascii in one of our tools. Having maya installed on the system it is running is possible, tho i would of course prefer it to be self contained.

Regards,
Thorsten

Doing it without Maya is probably lots of work, as the MA/MB files are MEL script, executed from top to bottom, so you would have to write an interpreter for it and handle all of the modifiers that gets applied and all that.

I guess the applications you talk about use Maya in batch mode from command prompt, with a custom script that exports the scene into another format which is easier to use outside Maya, like FBX.

More info in the Maya help here:
User Guide > General > Basics > Interface overview > Work with menu items, tools, and options > Start Maya from the command line

You can use MLibrary class that comes with the c++ API to develop standalone applications. You don’t have access to any maya UI though which you probably don’t need. Hopefully this should work.

MLibrary class: http://download.autodesk.com/us/maya/2009help/api/class_m_library.html

@Wolfsong: Thanks, i was afraid it would be like this. This seems messy and unpredictable :confused:

@Lonewolf: Thanks a lot, that looks very interesting

If Maya is installed you should also be able to use mayapy.exe to run a Python script through Maya’s Python interpreter. You can then use PyMel or Maya.cmds to import the files and do any other Maya related commands. Hope that helps.

-Mike

Thanks mike, but that will not allow me to directly access all all the information contained within the file, would it? I would have to iterate using python and access all the geometry. That sounds as if it might be pretty slow.

Regards,
Thorsten

If you are making some sort of an “importer” like pulling the data from maya scenes instead of the regular type of exporters, check this example out on how to open scenes:

http://download.autodesk.com/us/maya/2009help/api/ascii_to_binary_8cpp-example.html#a12

You can then use the MIt classes to iterate on the DAG and use MFnMesh class to access mesh data.

[QUOTE=instinct-vfx;14745]Thanks mike, but that will not allow me to directly access all all the information contained within the file, would it? I would have to iterate using python and access all the geometry. That sounds as if it might be pretty slow.

Regards,
Thorsten[/QUOTE]

No problem. If you are parsing information from a Maya file through a standalone c/c++ application I would definitely agree that using Maya’s API would be much faster. However, if you are using Python or another language using mayapy I don’t think would be to bad of a speed hit.

Great stuff thanks a lot again guys. I am currently evaluating the possibility of loading maya files (or a feature subset) directly to get rid of some conversion steps. Every conversion is somewhat error prone in this case and hence i am trying to work of the source files if possible.

Regards,
Thorsten