MEL How-To #65

Back · Previous · Next Maya

How do I use MEL to get and set the Render Globals?

Most of the settings are defined in the "defaultRenderGlobals" node in the scene. You can query this node for the settings used in the render. Of course, you'll need to know the name of the attribute corresponding to the setting for which you need, and you'll need to know what its value means.

As a start, use the listAttr command to get a quick summary of all the attributes on this node. The following MEL will give you a sorted list:

string $globals[] = `listAttr defaultRenderGlobals`;
$globals = `sort $globals`;
print $globals;

The correlation between this node and the Render Globals window are managed by the MEL script:


You can activate the Script Editor's "Echo All Commands" and then toggle settings in the Render Globals window to see which MEL procedures are called in response. Note that the "renderGlobalsWindow.mel" script uses the UI for obtaining the current settings, defeating the ability to simply call the functions within it to specify your own setting.

Once you figure out what all the settings mean you can use the MEL commands getAttr and setAttr - targeting the "defaultRenderGlobals" node - to change the render settings as you see fit.


The Render Globals derives its resolution from the "resolution" node connected through its ‘.resolution’ attribute:

listConnections defaultRenderGlobals.resolution;
// Result: defaultResolution //

Knowing this, you can query the width and height from the connected "resolution" node:

getAttr defaultResolution.width;
// Result: 640 //

getAttr defaultResolution.height;
// Result: 480 //

To find other potential resolutions:

ls -type "resolution";
// Result: defaultResolution resolution1 //

getAttr resolution1.width;
// Result: 320 //
getAttr resolution1.height;
// Result: 240 //

The following tip was generously provided by both Mark Adams (Pixar Animation Studios) and John Cassella (Red Paw FX). Originally posted on the Highend3D Maya forum, I've paraphrased the content for these pages. Reproduced with permission from the authors.

Maya maintains its list of resolutions in the global variable $gImageFormatData, which is defined in, e.g.:


You could make a script that blanks this global variable and then add your own, each in the format:

"<Preset Name>   <width> <height> <aspect>"

Maya supports user-defined resolutions as stored in "userImageFormats.mel". The use of this file is described in Maya's documentation under "Rendering: Render Globals, Resolution Presets".

Renderable Cameras

The renderable camera is not specified by the "defaultRenderGlobals" node, but rather by the ‘.renderable’ attribute for each Camera in the scene. You'll need to query each Camera to find out which ones are flagged to be renderable; e.g.

int $isRenderable = `getAttr perspShape.renderable`;


Mark Adams, Pixar Animation Studios

John Cassella, Red Paw FX

Wednesday, August 29, 2001