In Blender's 'Render Layers' tab in its 'Scene' section there is a list of render layers. I wish to know how I can create a new render layer and customise that layer using a script.

For example, to create a render layer called "Characters" that only renders scene layer number 1 (ignore mask layers for now).


1 Answer 1


Create a new render layer with Scene.render.layers.new()

As a rule of thumb, I always use an API method such as new_render_layer = scene.render.layers.new(name) in preference to the operator, in this case bpy.ops.scene.render_layer_add().

Test code, creates a new render layer named "Characters". Makes it the active render layer. Sets only scene layer 0 (the first) as included, turns off zmask, and, just for fun, makes true for every odd zmask layer.

import bpy

context = bpy.context
scene = context.scene

new_rl = scene.render.layers.new("Characters")
# make active
scene.render.layers.active = new_rl
# set only layer 0 true 
new_rl.layers = [not i for i in range(20)]
# don't use z mask
new_rl.use_zmask = False
# every odd zmask layer
new_rl.layers_zmask = [not i % 2 for i in range(20)]

See RenderLayer docs for more render layer properties to set.

  • $\begingroup$ Thanks! This was helpful. The output window only ever shows the operator class commands. $\endgroup$ Mar 28, 2018 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .