View in #maya on Slack
@tool: Maya isn’t letting me append to MAYA_SHELF_PATH… any ideas?
trying to do os.environ["MAYA_SHELF_PATH"] = ":%s" % (shelfPath)
throws # Error: KeyError: file D:\Program Files\Autodesk\Maya2018\bin\python27.zip\os.py line 425: MAYA_SHELF_PATH #
@bob.w: os.environ["MAYA_SHELF_PATH"] = ";%s" % (shelfPath)
Try with a semi-colon instead of a full colon
@tool: tried as well
@bob.w: hmm. No idea, i’ve never tried to overload that one before.
@tool: even doing just
print "\n".join(os.environ['MAYA_SHELF_PATH'])
gives the same error
@bob.w: the second one just means there isn’t anything set to that variable
But I’m able to do os.enivron['MAYA_SHELF_PATH'] = 'derp'
without any problem
If you’re trying to get the shelf path first, and then recombine it, then yeah that will throw a key error
@tool: hmm…yeah I was trying to do +=
but I guess there’s nothing to add to yet…
@bob.w: os.environ['MYA_SHELF_PATH'] = ';'.join([os.environ.get('MAYA_SHELF_PATH', ''), *new_paths]
Though the star upacking won’t work in 2.7, but it gets the point across
Also misssed a closing parens on the join call
because I’m terrible
@tool: seems like it won’t make the shelf start on startup when doing that
well when putting the path in my userSetup.mel that is
@bob.w: Yeah, the path would probably need to exist before any of the userSetup
code is run.
userSetup.mel
is also fairly late in the startup process, it waits until the UI has finished loading
@tool: hmm…
@bob.w: userSetup.py
is run much earlier.
@tool: same folder as userSetup.mel?
@bob.w: maya.env or a module file is where you can safely assign environment variables so that they are seen by the application at startup.
If you want shelves loaded from a custom path, and don’t want to use one of those options, you’ll probably need to manually load the shelf from code.
@tool: yeah other than trying to make the .py or .mel do the maya.env I don’t know if I can do that cause right now we dont’ have a central repo/location for maya stuff
how do I load a shelf from code? can’t see anything other than loadNewShelf which doesn’t seem to load it…
@bob.w: Honestly, I’m not sure how to load a mel defined shelf from code. I’ve written my own shelf loader a few times over the years. The latest one is included in mGui.
@tool: hmm
@bob.w: You can see how it works from the examples: https://github.com/theodox/mGui/tree/master/mGui/examples
GitHub: theodox/mGui
It basically defines a shelf as a json file, and loads that
either into a main maya shelf, or in newer versions of maya, onto a floating shelf.
The advantage to this method, is that users can insert their own buttons onto the shared shelf, and the loader won’t wipe those out when updated.
@tool: hmm, seems I can do loadNewShelf “fullpathToShelf.mel”
so might just have to try to rip the path from the env
@bob.w: https://github.com/wvlia5/SublimeDebugger look like it has some of this stuff, but its failing pretty hard on a simple test script with import errors for modules I know are on the python path
GitHub: wvlia5/SublimeDebugger
yeah, it looks like it is running the debugging session inside the sublime python session instead of inside an external python.
But it does at least do breakpoints and follow along with super simple scripts.
@tool: so…is there a way to make maya NOT cache/save a copy of a shelf to the docs/maya/version/prefs/shelves folder?
finally got it to load my shelf but then on exit it saves a version and doesn’t load from my repo anymore…which is very counter productive…
@bob.w: Not that I know of, you can walk the list of available shelves, and delete any that exist with the same name as yours, and then call load.
@tool: hmm that might work
@rgkovach: add the location of your shelf to Maya’s Shelf Path and it should not try to make a backup
MAYA_SHELF_PATH
@bob.w: Yeah, he was trying that one earlier. The problem was not being able to update that path once maya had started
@rgkovach: setting it with maya.env?
@bob.w: The impression I got was that the location would be a bit variable depending on the machine as they didn’t have a specific guaranteed location
@rgkovach: oh, might be too late to add to it once Maya has already started up
@bob.w: so hard coding it into maya.env would be a bit tricky
@rgkovach: don’t modules allow defining their own shelf locations?
@bob.w: Yep
They can do their own plugin / script / shelf / icon and probably some other path(s) I’m forgetting
Not to mention adding addition ENV variables as needed
And triggering their own init / userSetup scripts
@tool: might have to figure out how to do modules then…
@bob.w: So that they can be configured if loaded at runtime
@tool: it’s that OR on startup just making the maya.env if it’s not there already I guess
@bob.w: Startup it to late to edit the maya.env
@tool: cause yeah on load I am adding the shelf path to MAYA_SHELF_PATH and it’s loading it
ah lame…
@bob.w: Maya.env is loaded before the python interpreter
@tool: well I could actually make it when I copy over my start up scripts I guess
@bob.w: That’s basically what our global installer does for us
@tool: (py script to copy them for artists currently…)
yeah I wish I had a loader so I could just chuck this in there before launch…
@bob.w: it adds the lines needed for Maya.env to point at our module location
Which is relative to our tools workspace, so on the off chance someone is using a machine not configured the same as our local boxes (aka outsourcers) don’t have to deal with hard coded paths
@theodox did a pretty good writeup on modules a few years ago http://techartsurvival.blogspot.com/2014/01/mayas-mildy-magical-modules.html
Maya’s (mildy) Magical Modules
@tool: hmm interesting
@rgkovach: you can assemble the environment ahead of running the maya application, then you don’t need to mess with userSetup, Maya.env, or modules.
@bob.w: @bob.w uploaded a file: Untitled and commented: This is a rough example of a super complex one that I was using at an old job. This helped me in deploying a single toolset across 5 different versions of Maya for 3 or so projects.
@tool: there’s so much more magic in Maya lol
@bob.w: Maya is all the magic
@tool: I was hoping I could just lazily setup what i got going in max now, which is a startup file that copies over new ms scripts that basically just call a python include and run from the perforce repo of the user
but if Maya is gonna cache and not do shit then I have to do all this more complex stuff like mods lol
@bob.w: Yeah, Maya’s deployment stuff is way more flexible, but that flexibility comes at a price
personally, with that above posted module, i wouldn’t follow the pattern of actually stating the modules install location. Instead, I’d just put the module file where I need everything, and just make it relative to that.
@theodox: modules will allow you to point at net shares if that’s what you want to do
@tool: it’s more that I have no idea what everyone has named their perforce workspace I guess?
and the possibility that there’s more than one because of cross projects and such
@theodox: I think you could make an ownerless client which mapped just what you wanted and call it explicitly
p4 -c my-special-client sync \\depot\maya_tools
or something along those lines
@tool: O_o (sounds like witchcraft)
@theodox: It’s been a long time since I looked at it – I don’t use p4 for tools deployment myself – but I think it is possible to make a client that doesn’t belong to a specific user or machine and do it that way. May be mis-remembering though
@tool:
+ AwesomeTools 1.0 Path/To/Repo
PYTHONPATH +:= scripts
MAYA_SHELF_PATH +:= shelf
Something like that might work? Cause I could make that easy enough in the setup script (to copy the startup files and such)
scripts and shelf being folder names in “Repo” folder?
@theodox: I’m pretty sure you need to set a module shelf path instead of overriding the env var
@tool: so that would just be like shelf: shelfFolder
then?
@tmoore: I’ve been using a setup where I have an install script that copies the .mod file and the module directory into the MAYA_MODULE_PATH location so I can use a relative path in the .mod file
@tool: or does that get chucked in scripts
@rgkovach: sounds like you need your deployment to provide information that maya can use for startup
@tmoore: + maya-toolModule 1.0 ./toolModule
@theodox: oh wierd, it looks like modules append to /scripts /icons and /presets but NOT shelves!
@tool: yay…
@theodox: yeah, shelf distribution is not a first-class citizen – that’s why we did our own in mGui
@tool: I’ll just force a maya.env…
@theodox: but even then I don’t think you’ll get persistence, that’s a user side thing no?
@tool: not a clue
@tmoore: I suppose the question is, do you really need a shelf? I opt for menus generally. Though the menu bar can get pretty crowded…
@tool: I’m starting to think, no, and yes I should probably just do a menu instead. does a menu get auto added to hotbox or do you have to special make that as well
@tmoore: I’ve never checked before, but looks like they auto load
so that’s pretty cool
I’ve been toying with something that would automatically translate menu commands into a dockable toolbox
@bob.w: Yeah if its on the menubar, its on the hotbox
@tmoore: but I’m pretty far from having that work
@tool: well menu it is then I guess goes to figure out how to Menu now…
@bob.w: Yeah, I used to push both a menu and a shelf, somewhat to accommodate different users, but also because we had different tools / uses for both.
mGui also provides a menu loader
Just saying.
@theodox: yeah on investigation it seems like shelves and shelf states are treated as a subset of user preferences
@bob.w: total
@tool: haha
@rgkovach: if you can get a location from your overall pipeline, like a branch location or project directory, you can give that to maya and build off it to find your code and shelves.
@tool: I know where the project is
@bob.w: p4 where //depot/project/root
should be enough to get that
@theodox: menus are much easier, since they can be 100% code if you want – just put each menu into a python file with a ‘build’ method or something, import and run in your setup routine
@rgkovach: you just need to have a small batch program or script find that data and then call Maya so the Maya process has access to that path.
@theodox: the only tricky thing with menus is that you will have to wait for Maya to finish loading if you want to append to existing menus instead of making new ones
there’s a bunch of mel crap that goes on and you can’t know whether it’s done until scene load
@bob.w: Yeah, and you have to trigger a load on those menu’s or they’re empty at startup.
@theodox: The workaround for that’s in the menu loader, bob? I forget now. I know I’ve done it for our work toolkit
@bob.w: I’ll have to double check, I think so. Though I might have it conflated with the one Jeff made here for the volition tools
@tool: right now I’d kill for a wizard TA to learn more stuff like this from haha
like in house
@bob.w: yep, looks like we exec the pre menu command in mgui
Oh yeah, having someone onsite to brain leach from is awesome.
@tool: #oneDay