Store Data in Maya

I was recently approached by a client who wanted me to create a bespoke tool for them in Maya. This was a unique and complex task, the type I love, and as the scope of its development grew so did the need for even more flexibility.

The client wanted the ability to add and remove elements at will, save the file, strip it down and then also regenerate everything should the need arise. The solution was to find a way to store key data in the scene, so it could be referenced later.

This is quite a common question. Storing data can aid in a variety of ways ranging from simple user interface input to retaining a vast array of skin weights.

As with anything in Maya there are several ways to approach this type of problem.

The most obvious would be to use a node which exists in the scene. This can then have attributes added which store the data and can be easily accessed later. The problem with this approach is a node can be accidentally deleted if not hidden correctly. You can help to avoid this by using a non-DAG object, like a network or unknown node which won’t show up in the outliner by default.

If you are looking to script a solution, the command I use most frequently is fileInfo. Rather than storing the data as a node which sits in the scene, this writes the data into the file header. Just like the node approach this can then be easily accessed and used when needed. Unfortunately, the fileInfo command also has a drawback and that is if the file is imported into Maya rather than loaded the data doesn’t come with it.

Another script based approach is to use optionVar. This is more limited than using fileInfo but is ideally suited for retrieving data which has been input into a user interface.

These are just a few options available but are the most widely used. Experiment with them and see which suits your project the best.

TOP TIP

If you chose to use a node to store your data, you can help to secure it using the lockNode command. This will lock the node in the scene, preventing it from being deleted or edited by mistake.


 

Reposted with permission from 3DWorld Magazine

 
Previous
Previous

Four Joint IK Chain

Next
Next

Become a Better Artist