Hi there, Matt again with the Maya Learning Channel.
So have you ever gotten your hands on a really cool scene file,
only to load it up and find yourself faced with errors like this?
And even when the scene does load up, it's missing all its assets and textures.
Well in this quick tip, I’ll show you how to fix and even prevent these kinds of issues,
by explaining the different ways that Maya looks at your hard drive for assets.
The first thing you’ll want to try is setting a current project, in order to use relative paths.
At its core, Maya refers to external files in one of two ways:
either by absolute paths or relative paths.
Absolute paths point to an exact folder – no ifs, ands, or buts –
meaning that in order for someone else to use them,
they need to have the EXACT same folder structure on their computer.
So for example, if I click this tire and check its shader tab,
you can see that the texture file points to D:/Maya/newyork/lookdev.
But if I look here, you can see that my files are actually in D:/Maya/projects/newyork.
This is really easy to miss,
and is the most common cause of broken textures and references.
Now I could attempt to fix this one texture by manually rerouting its path,
but there are a lot of other missing textures too.
If I had to fix them all like this, I might tear my hair out.
So instead of doing all that work, let me first try going to File > Set Project.
You can also do this from any other file dialog window via the Set Project button.
Now I’m going to set the project as the root folder of the scene I received
– that’s the folder containing all the scenes, assets, and textures associated with this file.
And once that’s done, I’ll load up the scene again…
…and voila, no more broken references!
So why did this work?
Well, if I go back to look at the tire again, notice that the path is a little different.
This time, it starts at the “lookdev” folder instead of at my D:\ drive.
This is a relative path, and the advantage of using it
is that I no longer need to worry where I put this project folder on my hard drive.
Maya will only start looking for paths relative to the project folder.
Okay, so what if I set the current project but get this message about a missing workspace?
Then when I reopen the scene, everything is STILL broken?
This usually indicates that the original file creator never set a project properly
when they created it in the first place.
In this case I WILL need to fix all the paths myself,
but thankfully I can still do that without having to touch each one individually.
Instead, I can use the File Path Editor.
This shows me every single external dependency in the scene,
and even groups those that share the same absolute paths.
These red X’s indicate which paths are broken.
So I’ll select a broken path group and click the Repath Files button.
From here, I could just redirect this one group of paths.
…or I could turn on the Subdirectory search,
...and then select ALL the broken paths at once.
This lets Maya do all the work of searching and fixing the appropriate paths for me.
And now that the new paths are all valid again, I can go to the Reference Editor to reload
all my referenced assets.
Along with all their textures.
The beauty of this is that if I go back and select my tire again...
...you can see the path has changed to a relative one since we set a current project.
This means that if I save the scene and send it off to someone else...
...they won't encounter the same file pathing errors that plagued the original.
Remember though, relative paths ONLY apply to assets found within the project folder.
Anything I refer to outside the folder – say, for example, assets stored on a network drive –
will remain absolute even if you have a current project set.
This is actually useful if you want to source a network folder,
or mounted Google Drive or Dropbox folder where other artists might be making changes.
That way, you can synch to the network for the newest versions of files.
You can even use the File Path Editor to remap already-valid filepaths
to look at a network drive instead if you prefer.
For example, I can force the HDR image of this skydome to point to a network drive
if I expect it to be updated over the course of the project.
All I need to do is turn on this "Repath" option.
Now if anyone changes the source image, my scene will stay up to date automatically!
Smart use of projects can really save you a lot of time and effort throughout your pipeline.
Another thing to note is that the current project is saved to your prefs when Maya is closed.
In other words, if you close Maya and reopen it, the current project will remain the same.
However, this also means that if I delete Maya’s prefs folder
or experience a crash before closing Maya properly, the prefs won’t be saved.
In both cases, you’ll want to once again set the Current Project before you begin working.
To guard against against this, manually save your preferences via File > Save Preferences
once you set your project.
Finally, there is one other quick way to edit multiple paths,
though I'd only recommend it as a last resort.
If you save your files as .ma, they actually become readable in a text editor.
From here, you can do a simple search and replace on any absolute paths.
Just replace the portion before the project folder with nothing to delete it.
Just be careful – accidentally fiddling with anything else in here may corrupt your file.
Which is why I always recommend saving it as a copy.
Again, this is more of a last resort reserved for experts who really know what they’re doing.
I’d always recommend using the File Path Editor first.
Finally, it’s worth noting that the File Path Editor can’t fix nested references.
So if your references contain broken references themselves,
then they'll need to be fixed in the original assets first.
Of course, keeping files clean like that is just good general practice.
And those are the basic rules of filepathing in Maya.
Understanding them will fix 90% of your broken reference / texture scenarios.
As for the other 10%, there are a few exceptions
that involve things like Alembic and Arnold stand-ins.
I’ll cover those another video soon, so stay tuned!