How to get the Active Layer

You can get the scene name by:
bpy.context.scene.name
but I can’t find how to get the active Layer
I got this from the documentation:
“Note that in 2.8x, you get the active view layer from the active window, not the active scene.”
some help here!

Simplest is just to use bpy.context.view_layer.

If you need to set: bpy.context.window.view_layer = view_layer.

2 Likes