Render layers have been replaced by View Layers. Recommend do a search in the API docs or use the python console to figure out how to access the ViewLayers of the current scene:
>>> C.scene.view_
layers
settings
>>> for vl in C.scene.view_layers: # Iterate through all view layers
... print (vl.name) # print the name
...
View Layer
View Layer.001
View Layer.002
...
You can also access the current ViewLayer (in context) by using bpy.context.view_layer (or by using C
convenience variable in the console C.view_layer
):
>>> C.view_layer # View layer reference
bpy.data.scenes['Scene'].view_layers["View Layer"]
>>> C.view_layer.name # View layer name
'View Layer.001'
Another way is using get(<LAYERNAME>)
on Scene.ViewLayers
collection:
>>> C.scene.view_layers.get('View Layer')
bpy.data.scenes['Scene'].view_layers["View Layer"]
>>> my_vl = C.scene.view_layers.get('View Layer')
>>> my_vl.name
'View Layer'
Basic example on how to set attributes of the current view layer (in context):
import bpy
# Get the current view layer
vl = bpy.context.view_layer
# Set uv pass attribute
vl.use_pass_uv = True
# Set normal pass attribute
vl.use_pass_normal = True
# Enable diffuse light passes
vl.use_pass_diffuse_direct = True
vl.use_pass_diffuse_indirect = True
vl.use_pass_diffuse_color = True
Example on how to enable the 'UV' as well as the 'Normal' pass on all view layers in the scene:
import bpy
for vl in bpy.context.scene.view_layers:
vl.use_pass_uv = True # Enable UV pass
vl.use_pass_normal = True # Enable normal pass