> 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.
|