From: Greg Ercolano <erco@(email surpressed)> Subject: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 17:16:02 -0400 |
Msg# 1631 View Complete Thread (10 articles) | All Threads Last Next |
> I know I can add commands to "initialStartup.mel" [Ed: current versions of Maya use "userSetup.mel"] > to add menus to Maya. > > What MEL commands can I add to make a 'Rush' menu > that can open 'submit-maya' with the scene filename, frames, and renderer > preset when the interface comes up? > > Also, is it also possible to have menu items that open 'irush' and 'rushtop'? Yes, here's some MEL commands that should work. See caveats below. [NOTE: the mods described later in this thread have been applied to the example shown here -ed] --- snip // OPEN RUSH SUBMIT SCRIPT global proc RUSH_Submit() { // CUSTOMIZE THIS PATHNAME FOR YOUR ENVIRONMENT // | // \|/ // v string $submit_maya = "//meade/net/rushscripts/submit-maya.pl"; string $sfrm = `getAttr defaultRenderGlobals.startFrame`; // get startframe string $efrm = `getAttr defaultRenderGlobals.endFrame`; // get endframe string $scene = `file -q -sn`; // get scene name string $defren = `getAttr defaultRenderGlobals.currentRenderer`; // get default renderer if ( $scene == "" ) { error("No scene file"); return; } // Determine renderer string $renderer = "maya(sw)"; if ( $defren == "mentalRay" ) { $renderer = "mentalray(mr)"; } if ( $defren == "renderMan" ) { $renderer = "renderman(rman)"; } // Invoke submit-maya with scene pathname and frame range RUSH_Start("perl " + $submit_maya + " -field ScenePath \"" + $scene + "\" " + " -field Frames " + $sfrm + "-" + $efrm + " " + " -field Renderer \"" + $renderer + "\" "); } // TELL OS TO RUN A COMMAND IN THE BACKGROUND // This ensures the command runs in the background to prevent // hanging up the Maya interface while command is running. // Also makes sure rush/bin is in the path. // global proc RUSH_Start(string $cmd) { if ( gmatch(getenv("OS"),"*Windows*") ) { // WINDOWS $cmd = "start " + $cmd; if ( gmatch(getenv("PATH"), "*c:/rush/bin*") == 0 ) // Add rush to path only if not already { putenv("PATH", "c:/rush/bin;" + getenv("PATH")); } } else { // UNIX $cmd += "</dev/null >/dev/null 2>&1 &"; // prevents OSX hang putenv("SHELL", "/bin/sh"); // Use /bin/sh to run commands if ( gmatch(getenv("PATH"), "*/rush/bin*") == 0 ) // Add rush to path only if not already { putenv("PATH", "/usr/local/rush/bin:" + getenv("PATH")); } } print("Executing: " + $cmd); system($cmd); } // ADD A "RUSH" SUBMENU TO MAYA'S MAIN MENUBAR // These should be run only once in GUI mode (non-batch mode) // if ( `about -batch` == 0 ) // avoids warnings in maya 2016 -- added 06/21/2017 { setParent "MayaWindow"; menu -label "Rush"; menuItem -label "Submit" - command "RUSH_Submit();"; menuItem -label "Irush" - command "RUSH_Start(\"irush\");"; menuItem -label "Rushtop" - command "RUSH_Start(\"rushtop\");"; }; --- snip CAVEATS You can just paste these commands into the Maya "Script Editor" to test them out. When executed, these commands will create a 'Rush' menu in Maya's main menu bar. Clicking 'Submit' will bring up the submit form. There's also shortcuts for 'Irush' and 'Rushtop'. Later you can add them to your Maya "initialStartup.mel" script to make them run automatically whenever Maya is started. (Or in versions of Maya 8.5 and up, 'scripts/startup/userSetup.mel') These commands take advantage of the Rush 102.42a8 (and higher) version of the submit-maya script which accepts command line arguments to preset fields in the submit form. To see the syntax of this, invoke submit-maya.pl with the -help argument (again, only available in 102.42a8 and up), eg: perl //yourserver/rushscripts/submit-maya.pl -help COPY/PASTING NOTES When pasting the above MEL commands, watch out for line wrapping; I posted this message with line wrap disabled, so assuming your message reader window is wide enough, the lines won't suffer from line wrap when you paste the commands. Just be sure your message reader's window is wider than the longest line in the MEL script. |
From: Gary Jaeger <gary@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 17:35:03 -0400 |
Msg# 1632 View Complete Thread (10 articles) | All Threads Last Next |
that's cool. except for me, it does hang up the maya GUI while the
command is running. maya2008 OS X.
Also, how much can this be customized? Could the job name be derived from the scene name? And could there be a way to populate the Maya Flags with things like -cam, -x, -y etc? On Oct 22, 2007, at 2:16 PM, Greg Ercolano wrote: // TELL OS TO RUN A COMMAND IN THE BACKGROUND . . . . . . . . . . . . Gary Jaeger // Core Studio 86 Graham Street, Suite 120 San Francisco, CA 94129 (Tel# suppressed) http://corestudio.com |
From: Greg Ercolano <erco@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 18:05:06 -0400 |
Msg# 1633 View Complete Thread (10 articles) | All Threads Last Next |
Gary Jaeger wrote: > that's cool. except for me, it does hang up the maya GUI while the > command is running. maya2008 OS X. Ahh, you're right. This small change to the RUSH_Start() function should fix that: BEFORE: $cmd += " &"; AFTER: $cmd += "</dev/null >/dev/null 2>&1 &"; putenv("SHELL", "/bin/sh"); [NOTE: The above change has been applied to the previous article to ensure no one pastes the wrong example. -Ed] Here's the whole thing again with that included: ---- snip // OPEN RUSH SUBMIT SCRIPT global proc RUSH_Submit() { // CUSTOMIZE THIS PATHNAME FOR YOUR ENVIRONMENT // | // \|/ // v string $submit_maya = "//meade/net/rushscripts/submit-maya.pl"; string $sfrm = `getAttr defaultRenderGlobals.startFrame`; // get startframe string $efrm = `getAttr defaultRenderGlobals.endFrame`; // get endframe string $scene = `file -q -sn`; // get scene name string $defren = `getAttr defaultRenderGlobals.currentRenderer`; // get default renderer if ( $scene == "" ) { error("No scene file"); return; } // Determine renderer string $renderer = "maya(sw)"; if ( $defren == "mentalRay" ) { $renderer = "mentalray(mr)"; } if ( $defren == "renderMan" ) { $renderer = "renderman(rman)"; } // Invoke submit-maya with scene pathname and frame range RUSH_Start("perl " + $submit_maya + " -field ScenePath \"" + $scene + "\" " + " -field Frames " + $sfrm + "-" + $efrm + " " + " -field Renderer \"" + $renderer + "\" " ); } // TELL OS TO RUN A COMMAND IN THE BACKGROUND // This ensures the command runs in the background to prevent // hanging up the Maya interface while command is running. // Also makes sure rush/bin is in the path. // global proc RUSH_Start(string $cmd) { if ( gmatch(getenv("OS"),"*Windows*") ) { // WINDOWS $cmd = "start " + $cmd; if ( gmatch(getenv("PATH"), "*c:/rush/bin*") == 0 ) // Add rush to path only if not already { putenv("PATH", "c:/rush/bin;" + getenv("PATH")); } } else { // UNIX $cmd += "</dev/null >/dev/null 2>&1 &"; putenv("SHELL", "/bin/sh"); if ( gmatch(getenv("PATH"), "*/rush/bin*") == 0 ) // Add rush to path only if not already { putenv("PATH", "/usr/local/rush/bin:" + getenv("PATH")); } } print("Executing: " + $cmd); system($cmd); }; // ADD RUSH SUBMIT BUTTON TO MAYA'S MENUBAR // These should be run only once { setParent "MayaWindow"; menu -label "Rush"; menuItem -label "Submit" - command "RUSH_Submit();"; menuItem -label "Irush" - command "RUSH_Start(\"irush\");"; menuItem -label "Rushtop" - command "RUSH_Start(\"rushtop\");"; }; ---- snip -- Greg Ercolano, erco@(email surpressed) Rush Render Queue, http://seriss.com/rush/ Tel: (Tel# suppressed) Fax: (Tel# suppressed) Cel: (Tel# suppressed) |
From: Greg Ercolano <erco@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 18:45:48 -0400 |
Msg# 1634 View Complete Thread (10 articles) | All Threads Last Next |
Gary Jaeger wrote: > Also, how much can this be customized? Yes, you should be able to get as wild as you want. > Could the job name be derived from the scene name? Sure, MEL has lots of string manipulation commands to parse things like show/scene/shot info from the pathname, and pass that as the job title to submit-maya on the command line. submit-maya in 102.42a8 (and up) lets you preset /any/ of the fields in the submit form with the '-field' flag. To preset the "Job Title:" field, you would add the following to submit-maya's command line: -field JobTitle YOUR_TITLE ..in the RUSH_Submit() function. Not that I'm any MEL expert, but if your scene file pathnames looked something like this: //yourserver/jobs/<SHOW>/<SCENE>/<SHOT>/.. | | | | | [0] [1] [2] [3] [4] ..then you should be able to use MEL to parse that out with: string $scenefile = `file -q -sn`; string $words[]; tokenize($scenefile, "/", $words); string $show = $words[2]; string $scene = $words[3]; string $shot = $words[4]; string $jobtitle = $show + "/" + $scene + "/" + $shot; ..which you can then pass as to submit-maya with: RUSH_Start("perl " + $submit_maya + " -field ScenePath \"" + $scene + "\" " + " -field Frames " + $sfrm + "-" + $efrm + " " + " -field Renderer \"" + $renderer + "\" " " -field JobTitle \"" + $jobtitle + "\" " ); > And could there be a way to populate the Maya > Flags with things like -cam, -x, -y etc? I don't know MEL well enough how to get that info, though I assume it can be done. Certainly if you can get the info you want, you can pass it to the submit-maya script with: -field MayaFlags "-cam ... -x ... -y ..."; |
From: Gary Jaeger <gary@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 18:54:58 -0400 |
Msg# 1635 View Complete Thread (10 articles) | All Threads Last Next |
sickness! thanks Greg. I'll break it few times before getting it
right I'm sure.
that other fix worked for the GUI, btw. On Oct 22, 2007, at 3:45 PM, Greg Ercolano wrote: Yes, you should be able to get as wild as you want. . . . . . . . . . . . . Gary Jaeger // Core Studio 86 Graham Street, Suite 120 San Francisco, CA 94129 (Tel# suppressed) http://corestudio.com |
From: Gary Jaeger <gary@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 20:11:21 -0400 |
Msg# 1636 View Complete Thread (10 articles) | All Threads Last Next |
On Oct 22, 2007, at 2:16 PM, Greg Ercolano wrote: Later you can add them to your Maya "initialStartup.mel" script to make them run automatically whenever Maya is started. I can't get that to work. Any mel geniuses out there? I tried the initialStartup.mel as well as in userSetup.mel. Copying into the Script editor works, but I can't get it to work as a startup thing. Not sure what I'm doing wrong. Contact me directly if this is getting to OT for this list (greg?) . . . . . . . . . . . . Gary Jaeger // Core Studio 86 Graham Street, Suite 120 San Francisco, CA 94129 (Tel# suppressed) http://corestudio.com |
From: Greg Ercolano <erco@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 22:19:23 -0400 |
Msg# 1637 View Complete Thread (10 articles) | All Threads Last Next |
Gary Jaeger wrote: > On Oct 22, 2007, at 2:16 PM, Greg Ercolano wrote: > >> Later you can add them to your Maya "initialStartup.mel" script >> to make them run automatically whenever Maya is started. > > I can't get that to work. Any mel geniuses out there? I tried the > initialStartup.mel .. Meh, I meant userSetup.mel.. that's where it should go. > as well as in userSetup.mel. That should work, e.g.: OSX: /Applications/Autodesk/maya8.5/Maya.app/Contents/scripts/startup/userSetup.mel LINUX: /usr/autodesk/maya8.5/scripts/startup/userSetup.mel WINDOWS: C:\Program Files\Autodesk\Maya8.5\scripts\startup\userSetup.mel If the file doesn't exist, just create it. If it does exist, just add the lines to the bottom. Be sure the directory you tweak is the same version of Maya as the one you're running. And be sure the file is 'readable' to all users. I just tested it on those three platforms. Let me know if that doesn't help. |
From: Gary Jaeger <gary@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Mon, 22 Oct 2007 23:09:14 -0400 |
Msg# 1638 View Complete Thread (10 articles) | All Threads Last Next |
On Oct 22, 2007, at 7:19 PM, Greg Ercolano wrote: OSX: /Applications/Autodesk/maya8.5/Maya.app/Contents/scripts/ startup/userSetup.mel huh. /Users/gary/Library/Preferences/Autodesk/maya/2008/scripts/userSetup.mel works, as does: /Users/gary/Library/Preferences/Autodesk/maya/scripts/userSetup.mel but/Applications/Autodesk/maya2008/Maya.app/Contents/scripts/startup/ userSetup.mel doesn't. that's odd. maybe it's a permissions thing. anyway, works now! thanks . . . . . . . . . . . . Gary Jaeger // Core Studio 86 Graham Street, Suite 120 San Francisco, CA 94129 (Tel# suppressed) http://corestudio.com |
From: Greg Ercolano <erco@(email surpressed)> Subject: Re: [Q+A] How to add a 'Rush' button into Maya's menu Date: Wed, 10 Sep 2008 23:27:43 -0400 |
Msg# 1778 View Complete Thread (10 articles) | All Threads Last Next |
BTW, the same mel script code works for all versions of Maya 8.5 and up through 2012 and beyond. Just add the code to the "scripts/startup/userSetup.mel" subdir in whatever version of Maya you have, eg: MAYA 2008: OSX: /Applications/Autodesk/maya2008/Maya.app/Contents/scripts/startup/userSetup.mel LINUX: /usr/autodesk/maya2008/scripts/startup/userSetup.mel WINDOWS: C:\Program Files\Autodesk\Maya2008\scripts\startup\userSetup.mel If the 'userSetup.mel' file doesn't exist, create it. When you restart maya, it will be loaded automatically, and 'Rush' will appear in the 'Rendering' menu bar. The below mel script works on all platforms; OSX, Linux, Windows. > [Maya 8.5] > OSX: /Applications/Autodesk/maya8.5/Maya.app/Contents/scripts/startup/userSetup.mel > LINUX: /usr/autodesk/maya8.5/scripts/startup/userSetup.mel > WINDOWS: C:\Program Files\Autodesk\Maya8.5\scripts\startup\userSetup.mel > > If the file doesn't exist, just create it. > If it does exist, just add the lines to the bottom. > > Be sure the directory you tweak is the same version of Maya > as the one you're running. And be sure the file is 'readable' > to all users. > > I just tested it on those three platforms. > Let me know if that doesn't help. ---- snip: userSetup.mel // OPEN RUSH SUBMIT SCRIPT global proc RUSH_Submit() { // CUSTOMIZE THIS PATHNAME FOR YOUR ENVIRONMENT // | // \|/ // v string $submit_maya = "//meade/net/rushscripts/submit-maya.pl"; string $sfrm = `getAttr defaultRenderGlobals.startFrame`; // get startframe string $efrm = `getAttr defaultRenderGlobals.endFrame`; // get endframe string $scene = `file -q -sn`; // get scene name string $defren = `getAttr defaultRenderGlobals.currentRenderer`; // get default renderer if ( $scene == "" ) { error("No scene file"); return; } // Determine renderer string $renderer = "maya(sw)"; if ( $defren == "mentalRay" ) { $renderer = "mentalray(mr)"; } if ( $defren == "renderMan" ) { $renderer = "renderman(rman)"; } // Invoke submit-maya with scene pathname and frame range RUSH_Start("perl " + $submit_maya + " -field ScenePath \"" + $scene + "\" " + " -field Frames " + $sfrm + "-" + $efrm + " " + " -field Renderer \"" + $renderer + "\" " ); } // TELL OS TO RUN A COMMAND IN THE BACKGROUND // This ensures the command runs in the background to prevent // hanging up the Maya interface while command is running. // Also makes sure rush/bin is in the path. // global proc RUSH_Start(string $cmd) { if ( gmatch(getenv("OS"),"*Windows*") ) { // WINDOWS $cmd = "start " + $cmd; if ( gmatch(getenv("PATH"), "*c:/rush/bin*") == 0 ) // Add rush to path only if not already { putenv("PATH", "c:/rush/bin;" + getenv("PATH")); } } else { // UNIX $cmd += " > /dev/null 2>&1 &"; putenv("SHELL", "/bin/sh"); if ( gmatch(getenv("PATH"), "*/rush/bin*") == 0 ) // Add rush to path only if not already { putenv("PATH", "/usr/local/rush/bin:" + getenv("PATH")); } } print("Executing: " + $cmd); system($cmd); }; // ADD RUSH SUBMIT BUTTON TO MAYA'S MENUBAR // These should be run only once { setParent "MayaWindow"; menu -label "Rush"; menuItem -label "Submit" - command "RUSH_Submit();"; menuItem -label "Irush" - command "RUSH_Start(\"irush\");"; menuItem -label "Rushtop" - command "RUSH_Start(\"rushtop\");"; }; ---- snip |
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] |