Working with the Renderer

The render() function invokes the 3ds Max renderer, and takes many optional parameters to control the rendering independent of the current Render Settings Dialog settings.

By default this function returns an in-memory render as a bitmap value, but it will save the render to a file if the outputFile: parameter is specified.

For example, this function (from the render.py pymxs sample) saves the rendered output as a single-frame jpeg file to the system default #renderoutput directory, removing the current render if it exists:

def render():
    '''Render in the renderoutput directory.'''
    output_path = os.path.join(pymxs.runtime.getDir(pymxs.runtime.Name("renderoutput")), 'foo.jpg')
    if os.path.exists(output_path):
        os.remove(output_path)
    pymxs.runtime.render(outputFile=output_path)

Rendering Settings and Dialogs

You can change rendering settings using the pymxs.runtime.renderSceneDialog struct. Note that changes to render settings should be made with the dialog closed (which you can check with the renderSceneDialog.isOpen() function). See the "Render Scene Dialog" group of topics in the MAXScript Help for information about properties and functions in this struct.

The renderer assigned to each type of render target is held in the renderers struct. For example, by default, renderers.production is the scanline renderer:

>>> pymxs.runtime.renderers.production
<Default_Scanline_Renderer<Default_Scanline_Renderer:Default_Scanline_Renderer>>

The list of all available renderer classes is held in the rendererClass.classes list, and can be assigned to a render target:

>>> pymxs.runtime.renderers.current = pymxs.runtime.rendererClass.classes[5]()

Note: Because this list is accessed via Python, it is 0-based. Also note that you create an instance of the renderer class using the constructor notation.