Lazy Reference

This is more a thought than a tip, as I haven’t tested it.

In Maya, references are loaded by an absolute path.

cmds.file("c:\hulk\assets\bruce\model.mb", reference=True)

It could also contain environment variables.

cmds.file("$projectroot\assets\bruce\model.mb", reference=True)

But no matter what you do, you’ll always have to define at least some part of the hierarchy leading up to the file.

  • assets\bruce\model.mb
  • What happens when the hierarchy changes?
  • What happens when the same file exists in multiple places, depending on your studio?

Your tools can adapt, but your Maya scene can’t. The inner reference is forever hard-coded into the binary scene file. And there’s nothing you can do.

Or is there?

Solution

Take control of when references are loaded.

Maya has an option to open a scene and not load it’s references. That’s an opportunity for you to trigger a script on scene-open, parse information you stored on the reference-node itself, such as…

project: "hulk"
asset: "bruce"
family: "model"
instance: "highres"
version: "v032"

…use the resulting absolute path to replace the one initially saved with Maya and then trigger loading of the referenced file.

Now your Maya scenes benefit from the same flexibility as your tools, no paths involved.

Is this the “toggle” you have under Open Scene option box? Or do you mean in code.


A working solution for resolving references like this would be to use one of Maya’s scene callbacks, specifically:
OpenMaya.MSceneMessage.addCheckFileCallback(OpenMaya.MSceneMessage.kBeforeReferenceCheck, fn)

More information: Maya API MSceneMessage

Bam, sounds like a much better solution than the toggle.

This way, it could be done transparently!