To remove an existing View Layer using the Blender Python API, we need to execute the remove() method from the list of all view layers of the current scene.
To remove a view layer by name, we need to loop through all the view layers of the scene:
1 |
for layer in bpy.context.scene.view_layers: |
and if the layer name matches the given one, call the remove() method:
1 2 |
if layer.name == 'ViewLayer_001': bpy.context.scene.view_layers.remove(layer) |
Full code:
1 2 3 4 5 |
import bpy for layer in bpy.context.scene.view_layers: if layer.name == 'ViewLayer_001': bpy.context.scene.view_layers.remove(layer) |