PDA

View Full Version : Creating Render Layers With Command Line?


timdose
03-20-2008, 10:35 PM
Hi All

I have a script which checks which objects are in a group, then creates a separate render layer for each one of them. The idea is to break an object made of multiple parts into separate parts/images. Ideally, this would happen at render time, such that any file with a group of the correct name would have the render layers generated on-the-spot at render time.

When I source this script in Maya and execute the command- everything works fine. The render layers get created, I save the scene, and the scene renders happily from the command line, spitting out the expected zillion images.

However, when I run this exact same script as a -preRender script via the command line using the original, unmodified file, the command is executed (I can tell because it prints the expected output to the shell), but *nothing* renders. It prints the output from my script, then the next line says that the scene has completed rendering.

The script pretty much just uses "ls" and "createRenderLayer" with some loops- no AETemplates or interface macro-type commands...

Any thoughts on why the script would behave differently when run from the command line and cause no rendering to happen at all? Any input would be greatly appreciated!

Tim

timdose
03-21-2008, 10:29 PM
Well, I never managed to figure out why the command line renderer doesn't like render layers created by a pre-render MEL script. I suspect it picks out the render layers at file read, before the pre-render script is run.

Nonetheless, I was able to find a workaround which I'll mention in case someone else is running into a similar problem. The workaround was to use a script node that evaluates on file open to create the render layers. It runs automatically when the file is opened either by the batch renderer or through the Maya gui. Will have to put some kind of like on the file since it will create those render layers every time you open the file, which would be annoying if saved and re-opened as it would try to recreate the layers again. But that's fine, as the file that's actually being rendered is just a bunch of references to the files where the action actually happens. There may be some way to delete the layers if the file is opened in the Maya gui.

Basic process to create a script node that runs when the file is opened:

Window->Animation Editor->Expression Editor
Select Filter->By Script Node Name
Fill in Script Node Name & Script boxes, then click "Create" at bottom left
Execute on "Open/Close"
Script "Before"
(note: when editing the file later, you need to click the "Edit" button to save changes)

CGTalk Moderation
03-21-2008, 10:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.