MEL Commands for setting render global values?


hi all,

i have a doubt, i want to know how do i change the renderer and the renderable camera through MEL script.

  1. I want to change the renderer from Maya S/W to Mental Ray
  2. Want to change the camera from persp to some other camera. throu. MEL

Any help would be very useful for me to complete my script.




To set mentalRay renderer, use setCurrentRenderer mentalRay;

now there is no direct MEL command to set renderable camera,
so what you have to do is ,

  1. if you have only one scene cam “cam1” in you scene,
    then set renderable attr for all four default maya cams to 0.

    [b]setAttr “frontShape.renderable” 0;
    setAttr “perspShape.renderable” 0;
    setAttr “sideShape.renderable” 0;
    setAttr “topShape.renderable” 0;

[/b] and then , [b]setAttr “cam1Shape.renderable” 1;

[/b]this will automatically set “cam1” as renderable camera in Render Globals,

  1. if you have multiple cameras , then apart from default four cams you will have to pass the camera name to the procedure through argument,

you can do this thing manually by selecting the node “defaultRenderGlobals”, with

select -r defaultRenderGlobals;

and then go into attribute editor,

Hope this helps

Vishang Shah


Hai Vishang!!

Thanks a lot for the reply…it did work very well…

How do we change the resolution of the image thro MEL … i want to set it to HD720…

Thanks in advance!!!



first of all,
Maya will not show any feedback in script editor if you make changes in Render Globals window,
so you will have to “select -r defaultRenderGlobals”, then whatever changes you make will be shown in form of MEL code in script editor,

for example like in Resolution, if you want HD720, then take the width and height values from Render Globals and set it in defaultRenderGlobals node,

setAttr “defaultResolution.width” 1280;
setAttr “defaultResolution.height” 720;

this will set Resolution to HD720,

Vishang Shah


hi vishangshah vbmenu_register(“postmenu_4345076”, true); ,

i did it the same way,but could not find time in the evening to msg you. Also i have a small doubt…is it possible to open maya in command line and change the shaders to objs in it…and closing it as another file? like i want a GUI where i drag and drop the maya file from windows explorer and it should process the file ( changing shaders saving in diff file name). is it possible?

now i how i do it …i have to open the file and run the script… Kind of a .EXE program running in windows…but able to call maya and access it.

Help and suggestions would be appericiated.




here is one of the solutions,

you can use maya in its batch mode,

just type , mayaBatch -prompt , on run window,

it will open maya in command line with mel: prompt,
so now you can enter any MEL command in it,
for example, you can open any file with file -open and then list shader with ls command,

now to make it automate you will have to use this,

mayaBatch -file someMayaFile.mb -command “someCommand”

this will run your MEL command “someCommand” in you someMayaFile.mb without opening maya,

you can make a batch file of this command , and make another batch file which will call first one with multiple no. of files,

example to make this clear,
here I made 2 batch files and a mel file,
what this will do is open all .ma files from specified directory and delete a scriptNode from it and save it,

here is how to do:

first batch file,


SET path=“D:\Vishang Shah rash\props”
cd %path%
FOR %f IN (*.ma) DO CALL batDelUI %f

this will look for all .ma files and run batDelUI for it,


@echo off
echo Deleting uiConfigurationScriptNode for %1
mayaBatch -file %1 -command “source delUIConfig”
echo Deleting uiConfigurationScriptNode ended for %1

this will take .ma files transfered from props.bat and will run delUIConfig.mel command for each file,

so you can replace it with the mel file you have for assigning shader.
copy that mel file in maya/scripts directory

and put all your .ma files in one directory and specify it in props.bat,

so when all set, just go to command line and run props, and you are done,

for more reference on DOS batch programming ,

only thing is you can not have GUI for this, but for that you can take advantage from TCL or Python or Perl,

Vishang Shah


Hai Vishang Shah

That was really great!!! i am right away into this…experimenting…Hope to come out with what i wanted…

Thanks a lot again…

Is it better to learn Vc++ or python (truly i dont know where both are used withrespect to maya), also can u suggest some books for learning python or is there any institutes where they teach python.

I will let you know when i have done with what i wanted to…


Hi cagebee.

It depends on what you are developing. For writing core tools, C++, but for writing tools that depend on the core, i prefel python or mel. As for python, I use it a lot for scripting tools for blender and its a good language. You can do quite a bit with it.

Here are some links that should get you startedwith Python. It should take around a week to get comfortable with the language. Its easy and fun.

Python Tutorial (Written by creator of Python himself)

Learning with python

And the Python documentation is a solid reference.

Hope it helps.




go to :

its a forum for programmers, and python section is really good,
in that , starting python thread is awesome, it teaches python by little utilities, and projects,

I don’t know whether you use Perl or not for your pipeline,
here is a good link of Perl especially for our industry,

whether you use Perl or not, just read starting pages of above link, you will know a lot about languages being used in various productions,

hi iluvgfx, this is meta4 from CGTantra,
just said hi,

Vishang Shah


Thanks for this link man. I never knew about this site.

And, Hi meta4, a.k.a vishangshah.



Thanks sathish and vishang for your help and the link you provided…

Lots of information in the past few days…Thanks for that…

Also vishang i tried the mayabatch method u told it worked great i could achieve what i was looking for…but can i pass arguments thro this method to my script…

i got some prob with the double quote " stuff…

Ex: mayabatch -file test.mb -command “myScript(string argument)”

how do i pass a string here… i cant put it as

mayabatch -file test.mb -command “myScript(“cam_name”)” -> Its wrong…

How to pass string arguments in mayabatch command.



how are you?

past few days, surely there was a lot of knowledge exchange and networking,

now you were doing right

mayabatch -file test.mb -command “myScript(“cam_name”)” ->

just a little syntax correction, in command format

[b]mayabatch -file test.mb -command “myScript cam_name”

[/b]and the mel file will be accepting an argument for cam_name, like this;

[b]global proc testProc(string $cam_name){

print $cam_name;

it will work, I am glad that you solved your problems with multiple files,

take care,

Vishang Shah


hai satish and vishang…

Got a good link to learn python…it is certainly helping me… have a look

Hope it helps you guys also…




Hi, Anand,

thanks for the link , it surely has some nice contents, and google group looks fine to join too,

now here is a very nice link for maya+python

using this package you will not be restricted to using maya 8.5 for taking advantage of python,

like I am in production where we use Maya 7.0, so I can still write in python,

Anand & Satish,

if you know some nice link for Maya API Development, then plz post it,

this one :
is the best I have found so far and I am going through it, but if I can have 2-3 more links then learning fundamentals will become very easy,

Vishang Shah


Does anyone know the command to change the preset for image size in the render Globals?

While we’re on the topic :smiley:


vishangshah, you can always bye:
Complete Maya Programming: An Extensive Guide to Mel and C++ Api
by: David Gould

a realy good maya programming book

There is a second book too


hi Christian,
Thaks for telling about the book…

Changing image presets as Ben was asking,

i think there is no direct mel command…but wht i found was…

in the location were maya is installed there is a script folder inside that there is a folder called other…

C:\Program Files\Alias\Maya7.0\scripts\others

inside this there all lot of scripts that maintain all the imgae formats, rendering stuff and other stuff…may be can we find out the command to change the preset…

check this script : imageFormats.mel

Hope this info is of some use…



hi anand, how are you?

you suggestion about imageFormats.mel is correct but if you ask me I will not prefer to change in that file,
because its system side script not user side and is stored in program files,
in fact, in my company no artist has permission to access program files directory,

so as I have posted earlier, you can always change resolution in defaultRenderGlobals,

Maya will not show any feedback in script editor if you make changes in Render Globals window,
so you will have to “select -r defaultRenderGlobals”, then whatever changes you make will be shown in form of MEL code in script editor,

for example like in Resolution, if you want HD720, then take the width and height values from Render Globals and set it in defaultRenderGlobals node,

setAttr “defaultResolution.width” 1280;
setAttr “defaultResolution.height” 720;

this will set Resolution to HD720,

if you want everyone to follow some preset, you can add this mel command to userSetup.mel and store it to your My Documents/maya/scripts folder,
so whenever maya opens it will read it,

Guys, in my opinion ,don’t encourage artists to access program files, god knows what they will do to the system,

Vishang Shah


hai vishang…

i am doing good, how are you?

You are correct about artist acessing program files…chances are that they may screw up things…

My idea was from there cant we trace back or find some command that allows to change the presets in render globals…the method u said works…but still there must be some command to switch between presets…so my idea was to open the scripts in the "others
" folder and do some digging,

lots of stuff inside that folder…

Anyways someone might be knowing exactly how to get it done.

Also can anyone share a simple code where maya and python communicates… because i started off learning python (dive into python book) but still have no idea how to hook up python and maya… and if i do so how is going help me…Any ideas, suggestions will be appreatiated…

Thanks in advance


hey anand,

for python, which version of maya you are using?
if its 8.5 then there is good documentation regarding how to incorporate python in maya,
basically its same like you handle c++ API plugins,
maya 8.5 gives seperate plugin manager for python plugins, so store your .py files in there and load from plugin manager,

if you are using maya 7 or 8, then go here,

it will show how to workout maya+python,

and thanks for replying mail,
I cant tell you the project details I am working on, it will be violation of contract with my employer, but its international project, and big staff of artist working on it,

I am into developing tools for asset Creation team, and after 1-2 week, will start developing animation tools,

I am learning VFX now, not done much that side, but lets see, and know little rigging too,

python is good, but if you don’t mind, I suggest you to put some time on C++ API , because then we will not be limited to anything, and any package too, either maya, softimage or any other package,

just an opinion,
still python is good for writing fast pipeline tools for system and data management,

Vishang Shah