7
$\begingroup$

Does anybody know how to choose one or more from multiple defined render layers by name from command line or from the blender python console? To disable all render layers except the ones specified.

$\endgroup$

2 Answers 2

6
$\begingroup$

Here's a little script, that iterates over all render layers and checks for some condition (e.g. does the layername start with 's'?). Then it disables all render layers and enables one that fulfills the condition until there are no more layers:

import bpy

render_layers = bpy.context.scene.render.layers

for layer in render_layers:

    # some condition
    if layer.name.startswith("s"):

        # disable all
        for l in render_layers:
            l.use = False

        # re-enable a single one that matched the condition
        layer.use = True

        # RENDER HERE
$\endgroup$
1
  • $\begingroup$ I want to do rendering from specific layers and import an object into another layer at the same time. Do you know how to do that possibly? If so, could you please take a look at my question here and see if you can offer a solution? $\endgroup$
    – Amir
    Mar 7, 2018 at 20:43
2
$\begingroup$

A simpler solution would be something like the following:

import bpy
render_layers = bpy.context.scene.render.layers
for layer in render_layers:
  # some condition
  layer.use = layer.name.startswith("s")
$\endgroup$
0

You must log in to answer this question.

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