Maya Render All Files In Autosave Folder

For an university assignment I had to “display” my modelling progress. My instructor wanted me to do a screenshot every 60 seconds. However he was not impressed by the result. He wanted to see real renders.

To avoid interrupting my work every 60 seconds I enabled the internal “autosave” feature. Then of course I ended up with a ton of files. But now I still needed to render out every single file, so I created a simple script to render all files in the folder.

This Python script will create a batchfile which when exectuted will render every single file.

Create a Camera and Autosetup for Rendering

When rendering with Mental Ray I always use a dedicated RenderCam.

To create this camera I usually do the following

  1. Create the Camera
  2. Rename the Camera to “RENDER_CAM”
  3. Add the Lensshader “mia_exposure_photographic”
  4. Look through the Camera, Position it
  5. Do Test Renders

What really bothered me about this process, is that these steps are always the same and for Animations I forgot to set this camera as the RenderCam for Batch Render.

I created this short script to do these steps automatically:

 

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: <drive>:\Documents and Settings\<username>\My Documents\maya\<Version>\scripts
  • Mac OS X: ~/Library/Preferences/Autodesk/maya/<version>/scripts
  • Linux: ~/maya/<version>/scripts

Step 2

Copy and paste this script

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.

 

Use Atom as Python Editor for Maya

Atom is a neat text-editor created by Github. Atom can be extended with plugins and somebody already created a useful “atom-maya” plugin that enables you to send your current code to Maya.

Software Needed

Installation

Python

Simply download the installation files and follow the Installation instructions. During the installation of Python enable “Add Python.exe to Path”

Python

Atom

Simply download the installation files and follow the Installation instructions.

  1. Then open Atom
  2. Open the settings panel File > Settings (Ctrl+Comma)
  3. Go to “Install Packages”, search and install “atom-maya”.

2016-05-03 20_03_15-Settings — C__Users_info_Documents_einfuehrung-in-maya — Atom

Maya Configuration

To be able to send Code from Atom to Maya you need to open a command Port. We are going to set up Maya that this Command Port will be opened each time Maya starts.

When Maya starts it looks for a file called “userSetup.py” in the folder “/Users/<user>/Library/Preferences/Autodesk/maya/<version>/scripts“. If it exists it will execute the file.

Step 1

If the “userSetup.py” file does not exist – simply create a new file in Atom and save it as “userSetup.py” in the folder.

Step 2

Then add following lines of code:

Step 3

Restart Maya.

Test

Now that everything is set up, lets test if everything works.

Step 1

Open Maya and Atom.

Step 2

In Atom create a new file “test.py” add following code:

Step 3

Press “Ctrl+Alt+R” to send the code to Maya. If everything went ok, a polyCube was created.

Troubleshooting

“python” is not recognized as an internal or external command. : Run the python installer again and doublecheck if you set “add python.exe to path” (Or just add it manually to the windows system environment.

Script execution error. The plugin does not support python 3 : you can fix that by downloading python 2.