Just quickly tested another workflow with the new 'module' setup for Maya.
If you distribute your tool/plug-in as a maya module (with the .mod) file
you can include a userSetup.py within its own script folder.
No need to change any environment variables.
*Note I'm not sure how 'new' this module workflow exactly is with Maya; it
might only work on some of the newer versions like (2014+?)
Though they won't be copying over your 'module' into the scripts folder,
but to the designated spot for modules.
Also modules would allow you to contain your scripts, documentation,
plug-ins, icons all in its own folder not cluttering anything else of the
user.
And I think you know how to use the userSetup.py to create the menu. Aside
from getting the global mel variable: gMainWindow you don't need to use mel
commands.
I'm using maya.utils.executeDeferred() and just pass it a python function
as a reference.
Another thing to keep in mind is that the stuff you do in userSetup.py runs
in the global interpreter; if you rely on function names and someone else
overwrites it in their code in the global namespace of the interpreter it
will mess with your code.
I also tend to run the code in userSetup.py within its own function just so
I won't mess up anything globally, like so:
def __toolsetXUserInit():
print 'create menu and do awesome startup stuff'
__toolsetXUserInit()
del __toolsetXUserInit()
Hope this helps.
Cheers,
Roy
On Tuesday, January 20, 2015 at 3:44:32 PM UTC+1, Eric Thivierge wrote:
>
> Thanks Siew, I'll have a look.
>
> Eric T.
>
> On Monday, January 19, 2015 9:17:24 PM, Siew Yi Liang wrote:
> > Hi Eric:
> >
> > Here's some code from my scripts to get you going, I had to deal with
> > this recently, though I dealt with the userSetup config differently (I
> > expected my animators to be able to do that, but I imagine it wouldn't
> > be too difficult to write a quick batch file to just append the lines
> > you need :P ):
> >
> > http://pastebin.com/5cxxU9rL
> >
> > Ignore the evalDeferred, you can just use a mel.eval() if you're going
> > to be running it after MayaWindow is already built. Really the only
> > important thing is just getting that gMainWindow var from MEL, then
> > everything else is easy. :)
> >
> > http://pastebin.com/0nd05atr
> >
> > In Maya, if I just call the rigTools.start() method, it will build it
> > into Maya, so you can just assign that to a shelf button if you want
> > and then your artists can just click that button to have the new menu
> > added to the menubar, if that's acceptable. Otherwise the only other
> > easier way I can think of is to have it as a scripted plugin like Owen
> > said.
> >
> > Hope that helps!
> > Yours sincerely,
> > Siew Yi Liang
> > On 1/18/2015 4:27 PM, Eric Thivierge wrote:
> >> Is it possible to add a menu to the top of the Maya UI from a Module?
> >> I'm trying to build a small tool that I can distribute and don't want
> >> the users to have to edit their userSetup.py or similar to have it
> >> work. I just want them to drop a module into their module path and be
> >> done with it.
> >>
> >> Haven't found any info on this being available.
> >>
> >> Thanks,
> >>
> >> --------------------------------------------
> >> Eric Thivierge
> >> http://www.ethivierge.com
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Python Programming for Autodesk Maya" group.
> >> To unsubscribe from this group and stop receiving emails from it,
> >> send an email to [email protected]
> <javascript:>
> >> <mailto:[email protected] <javascript:>>.
>
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/python_inside_maya/CAAjrnHs8fUyoo4b_Uy%3Driant4E8aiN-u6dhyxOJHTfbc4hLsQQ%40mail.gmail.com
>
> >> <
> https://groups.google.com/d/msgid/python_inside_maya/CAAjrnHs8fUyoo4b_Uy%3Driant4E8aiN-u6dhyxOJHTfbc4hLsQQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Python Programming for Autodesk Maya" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected]
> <javascript:>
> > <mailto:[email protected] <javascript:>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/python_inside_maya/54BDBAB4.4000905%40gmail.com
>
> > <
> https://groups.google.com/d/msgid/python_inside_maya/54BDBAB4.4000905%40gmail.com?utm_medium=email&utm_source=footer>.
>
>
> > For more options, visit https://groups.google.com/d/optout.
>
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/a91509b7-aae2-41c3-ae22-21acc3dfc648%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.