The .bat file and PYTHONPATH aren’t the way to go for this, I think. What you should probably do is use a module, which you will define in a .mod file.
So first, what is a module? Well, you already use them. Folders like Documents/maya/2022
are basically modules. They’ve got folders for prefs, plug-ins, scripts, shelves, etc. And it auto loads userSetup.py. Modules follow that exact same folder structure, but give you more control.
Maya has an environment variable MAYA_MODULE_PATH. Any .mod files it finds in the folders on that path are treated as modules.
With a mod file, you can filter by different versions of maya and different OS’s. So you could say “For Maya 2022 on linux, add this folder to the MAYA_PLUG_IN_PATH, but for Maya 2022 on Windows, add this folder instead”. You can also create or add to any environment variables. Or you could say that instead of looking in the folder plug-ins
for plugins, it should look in a folder named bob
, or maya22Plugins
, or whatever
, or 2022/win64/plug-ins
.
Also, you won’t have to use a .bat file because this will happen any time maya starts.
For your use-case, I suggest adding a folder to the MAYA_SHELF_PATH
variable instead of using the built-in shelves
folder. In the shelves
folder, any time an artist closes maya, it will try to save a copy of that file to their Documents/maya/20??/shelves
and they start getting duplicates. That doesn’t happen with the MAYA_SHELF_PATH
(this is something that I’m dealing with at work right now)
So the contents of your .mod file would look something like:
+ MAYAVERSION:2020 PLATFORM:win64 animShelves 0.0.1 ./animShelves
MAYA_SHELF_PATH +:= customShelves/maya2020
+ MAYAVERSION:2023 PLATFORM:win64 animShelves 0.0.1 ./animShelves
MAYA_SHELF_PATH +:= customShelves/maya2023
So reading that first line from left to right: For maya 2020 on windows, make a module named “animShelves” with version “0.0.1” looking in the folder ./animShelves
(notice it’s a relative path!)
The next line uses this strange thing +:=
to mean “append this relative path to the environment variable”. So a folder ./animShelves/customShelves/maya2020
would get added to your MAYA_SHELF_PATH.
Then you’ve just gotta put the shelf files in those folders.
Unfortunately, the documentation for modules is TERRIBLE, but here’s a link.
https://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__files_GUID_130A3F57_2A5D_4E56_B066_6B86F68EEA22_htm