I'd like to run the script here but hit an error on the 2nd line:
view_layer = bpy.context.view_layer
Traceback (most recent call last):
File "/usr/lib/python3.6/code.py", line 91, in runcode
exec(code, self.locals)
File "<blender_console>", line 1, in <module>
AttributeError: 'Context' object has no attribute 'view_layer'
Autcompleting the bpy.context object does show there's no view_layer property...maybe the docs are outdated?