Sunday, 29 January 2012

rendering from the command prompt

The best way to render is not to have maya open at all. The problem however is that the uni machines have not been set-up for command line rendering and when you log into multiple machines maya can not find your preferences.

To sort this out we are going to create a file that runs a load of commands and then renders our scenes nice and quick.

We are using batch files (a simple text document saved with .bat or .cmd as a file type)

Copy below into a text document and save it to the x drive as myrender.cmd


REM gets all the maya commands

PATH=%PATH%;C:\Program Files\Autodesk\Maya2012\bin;

set MAYA_APP_DIR=x:\maya_temp_pref

set MAYA_PROJECT=X:\DATA\bouncing_ball

set TMPDIR=x:\temp

REM example render command (see manual for commands)

render -r mr -v 5

REM renders the next scene file (add another set MAYA_PROJECT if your other scenes are in a different project

render -r mr -v 5

Explanation of various bits:

@ECHO OFF - This stops it printing out all the commands to the console

REM - these are just comments and are ignored by the console

 PATH=... - This adds all the maya commands to the system path allowing access to them from the console
set MAYA_APP_DIR - This sets a local maya preferences (best to copy your ones from the server)
set MAYA_PROJECT - This sets the maya project you are working from
set TMPDIR=x:\temp - This sets maya's temp directory to be local rather than on the server
 render..... - This starts the render command, look it up in the help under Command line rendering to see all the options. You have access to more options than you do if you are rendering from Maya (this is a good thing)

Ok so now what??

Well to run this you need to open a command prompt. Windowskey + R then type cmd and press enter

You should be faced with a command prompt. Navigate to where you have saved your myrender.cmd file. (look up how to navigate in DOS if you don't know)

Once in the folder type .\myrender.cmd and all being well it will start.

Make sure you change the project directory to one of your project directories and the scene name to a scene you have. The really good thing about this is that you can get it to render more than one scene, as in the example above just have a second (or as many as you like) render line and once it has finished one render it will move on and do another. If the scene is in a different project you will need to set the project to the new one before the render line

This is great for setting going over night (or over a weekend).