PDA

View Full Version : Parsing Maya Binary Files with Java


Pyoeter
04-07-2005, 07:04 PM
Hello,

do you know a way to parse a Maya Binary with a java application? I want to read the renderglobal settings with the application. The Maya Ascii format is no problem, but I don't know how to get the numbers out of the .mb file. Already tried a lot of things and researched the net, but found nothing. I would be very thankful for advices.

best regards
Pyoeter

LordApophis
04-07-2005, 07:09 PM
You probably already thought of this but, you could always write the code in c and link against/call maya's classes to get that out of the mb and return it to java. Other than that I've never seen anyone parse out mb. I wouldn't mind knowing either.

playmesumch00ns
04-08-2005, 02:05 PM
The maya binary format's not an open standard... besides, it'll probably change hugely between versions.

The best way to read a maya file is to link against the Maya libraries and read it like that.

There's an example in the devkit for opening a binary scene and writing it out as ascii

Pyoeter
04-08-2005, 07:11 PM
Thanks a lot for your replies. I think they'll be helpfull. I know remarked, that the only solution to solve the problem, is to write something in c++.
So if I got you right, it is not possible to parse a mb file directly in an application. My first idea, after your posts, was to use the script in the devkit and to change the code that way, that the generated ascii file won't be saved as a .ma file, but will be written out to the standard out "cout". So I can run the c++ script out of my java application and read the resulting output. But after reading a bit in the Maya API I think thats not possible.
Do you know if there are methods to get the renderglobal settings out of a .mb file and write them to the standard out? I'm still researching in the API but for instance i haven't found anything.

I also could use your idea playmesumch00ns. But if possible I don't want to create another file.

Hope I will find a solution. The only thing that I programmed with c++ so far, was a simple "hello world".

Hoping to hear from you,
sincerely
Pyoeter

playmesumch00ns
04-09-2005, 10:56 AM
Sorry, I wasn't suggesting you actually write the file out as ascii, but that you'll have to write a Maya library application to open the mb file and extract the information you want. And you probably could just spout the info to stdout and read it back in from Java.

The render globals are stored on a node. I can't remember offhand what it's called, but it's trivial to find out. Then it's just a case of reading back the attributes.

tweeeker
04-10-2005, 11:35 AM
Do you know if there are methods to get the renderglobal settings out of a .mb file and write them to the standard out? I'm still researching in the API but for instance i haven't found anything.

The render globals in maya are a bit of a mess cause the attributes are stored accross a bunch of different nodes. I think for what your trying to achieve, check out the 'executeCommand' method of the MGlobal class. This lets you run a mel command from the api.

For example, to get the current resolution width, something like this should work:

//----------------------------------------------------
MString cmd = "getAttr defaultResolution.width";
int width;
MGlobal::executeCommand(cmd, width, false, false);
cout << "Width = " << width << endl;
//----------------------------------------------------

hope that helps

T

CGTalk Moderation
04-10-2005, 11:35 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.