Recommendations for creating a project Data File



So, I want to save out data, which can then be read later.

The Idea is that the User can create a Project with name X,
Define types of Actor (A Thing That Has Animation), eg:
Actor_Types: Characters, Beasts

Each Actor_Type has a set of animations, eg:
Characters: Walk, Run, TurnL, TurnR, Attack, Prance, etc
Beasts: Mosey, Canter, RendAsunder, FoulTheEarth, whatever

I am currently thinking nested Dictionaries of Strings and things.

I will be able to write these out into a txt, but can I read them back and put them into a useful var type for Maya?

Or is there a better way you might recommend?


If you’re thinking about a dictionary like serialization format, the standard there is json.
Python already ships with all the tools needed to save and load the format as well.

Definitely don’t try to roll your own, unless you really find that none of the already existing serialization formats out there work for you.


Just to get a bit more information . . .

How do you want to be able to use the saved data? Do you want to read it into a game engine as well as Maya?

Are you storing your animations as clips, or just figuring it out from frame ranges? Clips might be easier to deal with in some ways, although that might make importing elsewhere problematic, so you might have to settle for frame range with root transform.

Sending it to a file should be fairly straightforward. I’ve not used Python’s built-in JSON decoder in Maya, but if you can get it to work from Maya, that might be an easy out. (Edit: Bob beat me to it on this one. Curses.)

As far as storing inside Maya, you can do that on custom attributes or you can store it in a script node - depending on what you want to do with the data.


JSON is a great standard. YAML is a third party library but the files are much more human-readable and writable, so if you expect people to edit things directly at all it’s a good alternative.

If you want to store data inside maya files, cmds.fileInfo is built in for simple data – and if you make people use .MA files you can scan for your fileInfo keys without actually needing to open Maya, which is a nice bonus. fileInfo is a key-value store already, so if you don’t need nesting you are good. If you do want nesting, there’s a technique for that here.

Big thing to think through with this kind of data file is version control and centralization – who gets to edit the files, and when? And what happens if users make conflicting edits? No right answer necessarily but it’s something to have thought through


Big thing to think through with this kind of data file is version control and centralization – who gets to edit the files, and when? And what happens if users make conflicting edits? No right answer necessarily but it’s something to have thought through

Huge, HUGE agreement here. I’m at a startup right now, so we’re sort of still getting our system down, and we’ve already started wrestling with this - even with version control software, things can get dicey. My boss wanted to make some edits on one project, and pursuant to Murphy’s law, they conflicted with mine, so we had to get that sorted out. My boss does learn fast, though, so he’s sort of taking a hands-off approach now.

But ya, version control is a huge thing. Think about it early.


On a related note, you’ll need to consider what you want if there’s a network outage :slight_smile:



Thanks for your responses, everyone.

I’m looking in to Json though I suspect Yaml would be a better option for human-readability reasons, as mentioned.

Alas, these last two days I’ve had to be in school. And I am in again shortly, to show the lecturer what I have so far.

None of the actual coding and functionality… because I am not spending time setting up correct software versions, language versions etc…

I have to tell him The Question of my Project :expressionless:


And yes, Network Outage is a doozy.


I’m a big fan of yaml myself.
Major reason I recommended json is that it is included in the standard library, so less need to install things.


I must admit, because time is rather of the essence right now, I may start with Json, get that working. Built the UI I need in Maya and only then, if time allows, compile Yaml and prance up that merry tree.


Luckily you don’t need to actually compile anything with most of the yaml libraries for python. While they do have a compiled component, it is optional.
Its really just ensuring that all your users have a copy of the library.


currently it’S all very much a hypothetical.

and frankly, I will be disappointed if the coding teachers from school don’t have Python 2.7, and Yaml.

Though Maya 2016 is less likely.

I will definitely have to include instructions to set it all up, otherwise I’m not sure how they’ll mark it.


Hi, we’re currently using XML for our main projects DB, it’s easy to edit and easy to understand and decode.
A Maya tool extracts the data based on a specific project.
I admit I haven’t looked at YAML, so I can’t tell you the pros and cons, but back when I started in tools the XML setup was easy for me to setup and easy for project leads to add/edit data as needed.

If you need an example for this let me know.



Examples and docs would be great!

Perhaps too late for this particular project, but I’d still be interested to see any info you can provide, for future reference.