Best way to distribute custom shelves?

What is the best way to handle custom shelves in our tools? We have several studio specific Maya shelves that are kept as mel scripts in source control, loaded by adding a MAYA_SHELVES var to Maya.env. The problem is, If users may try to edit custom shelves and saveAllShelves, it fails with an error. Shelves before (left of) our read-only ones are fine, but shelves after (right) of can get badly messed up. I’m not 100% certain that our custom shelves alone are the cause -I suspect some of the custom shelf scripts the users apply (pose2shelf) are contributing.

I’ve written a few custom shelf libraries over the years, generally speaking I’d store the shelf information as json/yaml files and then rebuild them during startup. Generally the rebuild would happen in as little of a destructive way as I could, such that if a user added extra buttons to one of the shelves I’d just ignore them.
This of course would cause issues if a user copied a button onto a different shelf, as it wouldn’t update if the original button on the original shelf was changed, but that became an education problem.

My most recent shelf loading code actually exists in mGui, on the theory that adding it to an open source library would probably keep me from having to write it a sixth time. You can check the examples for the type of json file it draws from.


In my experience, it’s best to let users handle their own preferences and personnal shelves in maya.

I re build the shelf from the ground up everytime maya is launched with a customized class through a server side userSetup.
When I need contextual buttons depending on tasks, I also rebuild a shelf at scene opening.

Great idea!