Using Python, how do I get the name of the active render layer?

I have three render layers. All three are enabled. But only 1 can be "active." (highlighted in blue when I select it)

I would like to write a script that gets the active render layer name, appends it to the render Output filename, and only renders this layer.

Thank you.


2 Answers 2


bpy.context.scene.render.layers.active.name gets the name of the active render layer.


Short Answer

Use the following snippet to get the active render layer's name


Long Answer

Note: These steps build on each other; the complete code is shown at the end.

1. Get the scene

scene = bpy.data.scenes['SceneName']
  • gets the scene "SceneName"

scene = bpy.data.scenes[0]
  • gets the scene at index 0

scene = bpy.context.scene
  • gets the current scene

2. Get the render layers

layers = scene.render.layers
  • gets the render layers of the current scene (context.scene)

3. Get the active layer

active = layers.active

4. Get its name

name = active.name


scene = bpy.context.scene  # get the scene
layers = scene.render.layers  # get the list of layers
active = layers.active  # get the active layer from the list
name = active.name  # get the name of the active layer
  • $\begingroup$ Excellent. Just what I was looking for. Thank you $\endgroup$
    – mkschmitty
    Commented Oct 17, 2016 at 17:23
  • 1
    $\begingroup$ Isn't this just what I posted? $\endgroup$ Commented Oct 17, 2016 at 17:25
  • 3
    $\begingroup$ @RayMairlot The one liner is the same of course, but I felt it worth explaining just a bit more about how it came out. Your answer is correct (I up-voted it before I even wrote mine), but I don't think that it is very useful for those who want to understand it rather than just cut and paste :-) $\endgroup$
    – JakeD
    Commented Oct 17, 2016 at 17:28
  • 1
    $\begingroup$ I think if you felt it needed it expanding you should have commented that. If I see an answer that doesn't have enough information, I don't just generally post the same answer with slightly more detail. $\endgroup$ Commented Oct 17, 2016 at 17:33

You must log in to answer this question.

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