Modify File References before they are loaded

When working on multiple projects you might want to use assets from other projects.
Very often a file referencing pipeline makes this difficult though as Maya stores file references with absolute paths when you are not using Maya projects.

To avoid this you can hijack the Referencing procedure with a callback.

The callback triggers any function you define.
In the function you have access to the file path of the reference to do some checks and you can cancel the loading of the reference or manipulate the path to your liking.

Create a function somewhere in your pipeline.
Your function needs 3 parameters:

parameter 1 is the return code (a boolean to approve or cancel the reference load operation)
parameter 2 is the file object which holds the path and file information
parameter 3 is client data which you can pass in to your function from the callback

to create the callback for the file Reference use this code:

The function will be executed every time maya is about to load a reference.
You can even ask the user to browse for a new file when the current file is not in your project path for instance.
In the pipeline I am working on I inform the person that the file that is being referenced is not in the project path and ask, whether the user wants to load that file anyway or point to a new file.
This makes copying assets from one project to the other easier and also people will be warned that they are about to load a rig from a different project when opening a copied animation.
Is the popup annoying? Yes, maybe. But it definitely helps you softly enforcing all dependencies being copied to the right places 🙂

Please follow and like:

Leave a comment

Your email address will not be published.

*