one of the many features I missed from Softimage when using Maya, was the automatic switch of the active project when saving and loading scenes. This was super handy when working simultaneously in several scenes from different projects. Especially working in a small shop, where application environments aren’t well established. Maya has the recent projects menu command. And while useful, having to do that before opening a scene or saving one got tedious fast.
the first iteration of this script relied on
ScriptJob command to be called when saving and loading scenes. There was a big down-side to using that command because, as I later found out, ScriptJob is called last in the order-of-operations. Meaning, anything relying on relative pathing would break upon opening a scene from a different project. This is troublesome if references are being used in the scene!
so i decided to take another stab at it. Googling around for a bit, I happened across a couple of posts with similar goals, but no complete answer. Except, a mention of Maya’s
MSceneMessage has the option to be called before or after many scene IO related operations. And thankfully, has a handy function to grab the output from Maya’s browser window using
MFileIO. This was the final piece of the puzzle. And after some trial and error, was able to get it to work as expected.
at the heart of the code, I’m creating two
MSceneMessage callbacks before opening and saving scenes. Catching the path of the desired scene via
MFileIO and looping back through directories until I find a workspace.mel file. Then comparing that to the current project path.
this plugin relies solely on the presence of the workspace.mel file. If you’re not familiar, then I highly recommend checking out the docs. This file is key when establishing projects.
i hope the plugin is able to help or at the very least provide a point of reference. If you have any issues/feedback, let me know.