PDA

View Full Version : data from maya ta database (and vice versa)


katisss
01-14-2008, 04:21 PM
What is the best way to get data from inside a maya scene into a database (and vice versa)? Export separate .xml, read binary files, query sql via python? Any one tried?

Bonedaddy
01-14-2008, 07:41 PM
What is the best way to get data from inside a maya scene into a database (and vice versa)? Export separate .xml, read binary files, query sql via python? Any one tried?

We're on SQL here, so most of our db files are python sql calls. I'd think that xml would get really ugly really quickly, but I could be wrong.

Chadrik
01-14-2008, 10:06 PM
i think that MySQLdb has become the de-facto standard for database integration in maya.

http://sourceforge.net/projects/mysql-python

-chad

katisss
01-14-2008, 10:13 PM
ok, thats good news.
Is there any way of getting information from maya binary files via python?

Chadrik
01-14-2008, 11:47 PM
i don't mean to imply that MySQLdb comes pre-installed with maya, only that it seems to be the most common solution.

as far as maya binary files, i'd be very interested in this if someone had a package to do it, but i believe your best option would be to use mayapy (the maya python interpreter which you can find in the maya bin dir) to open the file in batch (non-gui) mode and get the info you need.

katisss
01-14-2008, 11:57 PM
i give that a try tomorrow.
I played with the python sql some weeks ago and it seems its a pretty good thing.

katisss
01-15-2008, 06:09 PM
Works well so far.
Why use mayapy over any other python?

Chadrik
01-15-2008, 07:23 PM
honestly, i don't use it that often, but i would like to make better use of it. mayapy is just a little shell script that sets up some environment variables before calling the python interpreter in the maya application directory. these environment variables must be set before initiating the interperter if you want to have access to the functions in maya.cmds. the advantage of using mayapy is that you can work interactively with a maya session from the python command prompt. to get access to the commands you must first run:


import maya.standalone
maya.standalone.initialize(name="python")


however, if using pymel, you can just import the pymel module and all will be setup automatically for you, including parsing environment variables from your Maya.env.

so, once you have everything initialized, you can use almost all non-ui commands to do whatever you want. since using maya commandline is faster to startup, requires less resources, and is less invasive to the artist who may be running your script, it's perfect for performing tasks behind the scenes that could not be performed without maya, such as getting info from an mb file, since to my knowledge it cannot be parsed.

also, if you have an IDE or text editor that supports executing python commands, you can provide mayapy as your interpreter and run commands directly from your text editor.

katisss
01-15-2008, 07:37 PM
I use IDLE and do the intialize thing at the moment.
Does this call the mayapy.exe? I wasnt aware.
Just testing if it works at all at the moment.

CGTalk Moderation
01-15-2008, 07:37 PM
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.