From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu
   Date: Mon, 12 Jul 2010 14:25:53 -0400
Msg# 1951
View Complete Thread (10 articles) | All Threads
Last Next
Greg Ercolano wrote:
>      The below mel script works on all platforms; OSX, Linux, Windows.

   In case you're trying to move away from mel, here's a python version
   that creates a 'Rush' button in the 'Rendering' menubar; put the following
   code in your Maya directory as 'userSetup.py'.

   Tested on Windows with maya 2010.
   If you have any trouble, feel free to follow up here.

   In the below, be sure to change '//meade/net/rushscripts/submit-maya.pl'
   to be your path to the submit-maya.pl script on your fileserver.

--- snip
# START SUBMIT FORM
def RUSH_Start(cmd):
    p = os.popen(cmd+" 2>&1","r")
    errout = "".join(p.readlines())
    err = p.close()
    print errout
    sys.stdout.flush()

# OPEN RUSH SUBMIT FORM FOR THE CURRENT SCENE
def RUSH_Submit():
    import maya.cmds as M

    # CUSTOMIZE THIS PATHNAME FOR YOUR ENVIRONMENT
    #                      |
    #                     \|/
    #                      v
    submit_maya = "//meade/net/rushscripts/submit-maya.pl"	# submit script
    sfrm   = M.getAttr("defaultRenderGlobals.startFrame")	# get start frame
    efrm   = M.getAttr("defaultRenderGlobals.endFrame")		# get end frame
    scene  = M.file(q=1, sceneName=1)				# get scene name
    defren = M.getAttr("defaultRenderGlobals.currentRenderer")	# get renderer
    if ( scene == "" ):
        M.confirmDialog(message="No scene file", title="Error", button="Dismiss")
        return

    renderer = "maya(sw)"
    if ( defren == "mentalRay" ): renderer = "mentalray(mr)"
    if ( defren == "renderMan" ): renderer = "renderman(rman)"

    RUSH_Start("perl " + submit_maya
              + " -field ScenePath \"" + scene + "\""
              + " -field Frames "      + sfrm
              + " -field Renderer "    + renderer)

# ADD RUSH SUBMIT BUTTON TO MAYA'S MENUBAR
#    These should be run only once.
#
def RUSH_CreateMenu():
    import maya.cmds as M
    M.setParent("MayaWindow")
    M.menu(label="Rush")
    M.menuItem(label="Submit",  command="RUSH_Submit()")
    M.menuItem(label="Irush",   command="RUSH_Start('irush')")
    M.menuItem(label="Rushtop", command="RUSH_Start('rushtop')")

# CREATE THE RUSH MENU WHEN THIS SCRIPT GETS LOADED
#     Only do this if not in batch mode.
#
if M.about(batch=False):        # avoids warnings in maya 2016 -- added 06/21/2017
    RUSH_CreateMenu()

--- snip

[EDIT 07/05/11: Clarified path change that's needed in script]

Last Next