/ MAYA, SCRIPTING

Set and load Renderer at Startup

Now and then Maya forgets to load “mental ray”. To avoid the hassle of having to manually load the plugin, I wrote a simple script that is executed by the userSetup.py (Maya searches and executes this file when Maya starts).

Step 1

First, create a userSetup.py file at following location: * Windows: _:\\Documents and Settings\\\\My Documents\\maya\\\\scripts_ \* Mac OS X: _~/Library/Preferences/Autodesk/maya//scripts_ \* Linux: _~/maya//scripts_

Step 2

Copy and paste this script

import maya.cmds as cmds def loadRenderPlugin(plugin = ‘Mayatomr’, name=’mentalRay’): if not cmds.pluginInfo(plugin, q=True, loaded=True): cmds.loadPlugin(plugin) cmds.pluginInfo(plugin, edit=True, autoload=True) cmds.setAttr(‘defaultRenderGlobals.currentRenderer’, name, type=’string’) print (‘# Result: %s Plugin loaded #’ % name)

Step 3

Now you have to add at the end of the file a line of code that loads the Render you are using. By default, Mental Ray will be loaded. However, you also can define a different function to load the renderer you are using like Arnold.

# Mental Ray maya.utils.executeDeferred(‘loadRenderPlugin()’)

# Solid Angle Arnold maya.utils.executeDeferred(‘loadRenderPlugin(“mtoa”, “arnold”)’)