Rendering with arnold in a python script

Rendering with arnold in a python script

Anonymous
Not applicable
14,411 Views
3 Replies
Message 1 of 4

Rendering with arnold in a python script

Anonymous
Not applicable

Hi,

 

I'm trying to render a camera using the arnold renderer by a python script.

I've tried to call the following functions:

 

cmds.setAttr("defaultRenderGlobals.currentRenderer", "arnold", type="string")

or 

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

But the output image is rendered using maya software (Because the AiSky I add is black) and no my camera is not pointing downward

 

I also tried importing arnold and doing something like:

 

from arnold import *
import os
import sys
 
AiBegin()

output = AiRender()

AiEnd()

But it does not seem to work either. (Output gives me "3")

 

Does anyone know how to do that ? 

 

Thank you

Accepted solutions (1)
14,412 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I fond this and it seems to work:

The following will render camera1 with arnold and will output a 1920 by 1080 px picture:

from mtoa.cmds.arnoldRender import arnoldRender
arnoldRender(1920, 1080, True, True,'camera1', ' -layer defaultRenderLayer')

But I still don't know what are the third and fourth argument. I can't to find any documentation on that command.

 

Now I'm trying to understand how to change the output format and output name of the render (using python).

Because right now I only have "untitled.exr"

 

0 Likes
Message 3 of 4

Anonymous
Not applicable
Accepted solution
# Rendering :
# from mtoa.cmds.arnoldRender import arnoldRender
arnoldRender(1, 1, True, True,'camera1', ' -layer defaultRenderLayer')

cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
cmds.setAttr("defaultArnoldDriver.pre", "file_name", type="string")

arnoldRender(200, 200, True, True,'camera1', ' -layer defaultRenderLayer')

Here's what I got.

 

These two commands names and sets the file format of the output image:

cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
cmds.setAttr("defaultArnoldDriver.pre", "file_name", type="string")

I still don't know what the third and fourth parameters of the arnoldRender() function do.

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hey thanks for the solution! Helped me alot on building a small pipeline. did some further work and want to share some findings.

 

i did a python help command on the arnoldRender function,

here is the result.

 

help(arnoldRender)
Help on function arnoldRender in module mtoa.cmds.arnoldRender:

arnoldRender(width, height, doShadows, doGlowPass, camera, options)

 

so there go the 3rd and 4th args, which still doesn't answer anything lol, but its something i guess.

 

 

Also for people who are looking for a quick way to get the full path of the render, you can do a

 

render_output = cmds.render('camera_name')

it will generate an empty file dictated by the render settings and populate the variable.

 

then you can run 

 

 

arnoldRender()

to make sure the empty file becomes the actual image. hope it helps for people still looking.