Matching references to file names

We want to use references in Maya as "proxies" so we'll only have one copy of the geometric data in a referenced file in the game and all worlds reference that single copy. This means that when exporting files we need the names of referenced files attached to particular objects. Unfortunately, the docs are pretty spare on information when it comes to references. It describes reference nodes in the DG reference but doesn't say how or where to access them. What's worse, it doesn't have an MFn class for them - the only compatible MFn class is the MFnDependencyNode so I can't use hasFn to recognize a reference node even if I try to walk through the DAG/DG tree. Even if I was able to find one, it's not clear how they hook the referenced items in the current scene. They've got a list of SetAttr strings according to the documentation, but I'm not sure what's in these. At the same time, you can get info as to whether a particular node is referenced and a list of all referenced files.

One option I'm thinking of is to write a special property on all top level objects when saving files which just has the file name. Then when exporting a file I can look to the standard Maya call to see if an object is referenced and if so, pull it's file name from the specially saved property.

Question is whether anybody has any better ideas or enough info about reference nodes to allow me to extract the information from them.

Thanks in advance!

Darrell Plank
darrellp@suckerpunch.com

I'm trying to also use references as "proxies" and have also run up against the same difficulty in getting information regarding the objects which are derived from the reference. During export of the scene I want to _not_ include the geometry of the referenced objects but I do want to dump the position and orientation of those objects into an external file for later use. So, for example, I can later render something there from a pool of candidate objects during game play.

Where is the relationship between the reference and the shape(s) (and transform(s)) in the scene stored? I.E. For a given shape that is actually from a reference how do I know it is from a reference during the export when the only info easily obtained off the reference dependency node is only the name of the node itself?

Thanks in advance.
Evan Carey

Look up the docs for the MEL 'file' command - it can be used to select the contents of referenced files, then you could query the selection. It's not pretty, but it might work:

file -sa "ref\_file";
$ref\_nodes = `ls -sl`;

The 'file' command can also be used to resolve project relateive paths to full paths and vice-versa. There's quite a bit of useful stuff in there that might help, specifically.