Question

Is there a way to basically print my own output during a command line render?

Let's say I don't need/want all the other output that maya spits out by default, I know you can change the verbosity level, but there's very specific things I'd like to output but I can't figure it out. I currently render out the verbosity output to file, so I wanted to print in the terminal (I'm using MAC) the frame that the render is currently up to.

This may just be simple minded, but here's what I tried:

Render -preFrame "print `currentTime -q`;" -s 1 -e 20 -rd /render/directory/ maya_file.mb 

Obviously, -preFrame expects a string, according to the docs this can take mel commands, but obviously this is limited to certain commands, I'm assuming the currentTime command is pulling the information from the timeline in maya, not queering it from the Renderer it self... When I run the above command, straight away, it spits out this: -bash: currentTime: command not found and soon after the render fails/doesn't start.

Idealy, I'd like to print the following as it starts each frame:

"Started rendering frame XXXX at TIME GOES HERE", that way, I can quickly look at the terminal, and see if the renderer has failed, stuck or where it's up to and when it started it.

So my question is, seeing is currentTime is a mel command used from within Maya, is there another way I could print this information?

Cheers, Shannon

Was it helpful?

Solution

After many hours of searching for this answer, I ended up finding out that you can start maya as an interactive shell. By doing this, I was able to source a script as I opened it, and run whatever I want into memory as If I had Maya open at the time.

/Applications/Autodesk/maya2014/Maya.app/Contents/MacOS/maya -prompt -script "/Volumes/raid/farm_script/setupRender.mel"

In the setupRender.mel file, I was able to assign variables, containing options for renders etc, in doing this, I was also able to create a global variable for the frame number, and increment it during the preFrame callback, like so:

int $startFrame                 = 100;
int $endFrame                   = 1110;
global int $frameCount         = 0;
string $preRenderStatistics    = "'global int $frameCount; $frameCount = " + $startFrame + ";'";
string $preFrameStatistics     = "'print(\"Rendering frame: \" + $frameCount++)'";
string $additionalFlags         = "";
string $sceneFilePath           = "'/Volumes/path/to/file/intro_video_001.mb'";

system("Render -preRender " + $preRenderStatistics + " -preFrame " + $preFrameStatistics + " -s " + $startFrame + " -e " + $endFrame + " -x " + $additionalFlags + " " + $sceneFilePath);

This is a very simplified version of what I currently have, but hopefully this will help others if they stumble across it.

OTHER TIPS

Take a look at the pre render layer MEL and/or pre render frame MEL section of the Render Settings.

It expects MEL, so you'll either need to write it in MEL or wrap your python in MEL. For such a simple use, I'd say just write it in MEL:

print `currentTime -q`

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top