Setting up Maya Hardware 2.0 using MEl/Python

Changing the render setting in Maya is straight forward, you can change the Hardware renderer very easily using Maya Render settings Window as you could see in the below image.

Hardware-render-settings (1)

But, how do you achieve the same thing using script code?

If you execute the following code, you will see that Maya renders using "Maya Software".

 

mel.eval('render -x 600 -y 800 "Render_Cam"')

or the same code as just MEL, Maya still renders using "Maya Software". In addition to the above code, the below python code is an attempt to change the renderer.

 

cmds.setAttr('defaultRenderGlobals.ren', 'mayaHardware2', type='string')

mel.eval('loadPreferredRenderGlobalsPreset("mayaHardware2")')

 

But Maya still renders using "Maya software".  The problem is, we have to set the current renderer. The following MEL commands will change the current renderer to Hardware Renderer 2.

  setCurrentRenderer "mayaHardware2";

 setAttr hardwareRenderingGlobals.renderMode 2 ;


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading