Occasionally, when I render a frame, my heart sinks when I see the first pixels appear in the Render View as I realise that I rendered the wrong camera.
I'm going to show you how to print the name of the render camera to the Output Window. And by modifying a Maya start-up script, you can make this a default feature.
Ideally, I would have the little yellow caption in the Render View say "Rendering...persp1", or whatever the camera is called.
Since that is not possible, I'll settle for seeing the camera name appear in the Output Window.
To achieve this, I'm going to modify an existing Maya script. Read this post for details of how to modify a Maya start-up script.
Copy the script renderWindowPanel.mel from the scripts/others directory to your user maya/ 2009/scripts directory.
Open the script in your favorite text editor and go to line 855:
// Perform the render
string $result;
Add the following line so the script looks like this:
// Perform the render
// owens modification:
// print current frame and render camera name to the Output window
string $currentFrame = `currentTime -q`;
trace ("\nRendering frame "+ $currentFrame + " with "+$camera+"\n");
// end of custom modification
string $result;
Previously in the script, Maya declares a local variable called $camera and determines which camera it is required to render, and assigns the result to the variable. The scope of the variable does not allow its value to be queried from within Maya so we would have to rewrite a whole lotta MEL to find it ourselves. It was quicker for me to find the start-up script that Maya uses and just add my own little modification.
I also query the current frame, before using the trace command to output the result to the Output Window.
Save your script, start Maya and render.
Check the top of the Output Window, and you will see the name of the render camera printed at the top.
Owen
Thanks Owen! So simple.
You have been very helpful
Posted by: Kiernan | 28/04/2010 at 02:45 AM
string $cameras[] = `ls -type camera`;
for ($camera in $cameras)
{ if (`getAttr ($camera+".renderable")`)
print ($camera+"\n");
}
..The Render Settings UI just checks the attribute "renderable" of each camera. This script does the same thing.
O
Posted by: owen | 27/04/2010 at 05:20 PM
Thanks for the article, but how do you query the name of the batch render camera?
(The name of the camera that appears in the Render Settings > Renderable Cameras Rollout > Renderable Camera:)
Posted by: Kiernan | 27/04/2010 at 09:28 AM