right now only there's the possibility of creating new view layers, but every time you create a view layer it defaults all layers to visible, and sometimes in the scene there are views that are too similar and when you got a lot of collections it gets painful to adjust the same over and over. Is there a way?
This little script lets you duplicate a view layer with its visibility settings only, render passes and cycles settings, render and selectable are settings that are shared among all layers.
import bpy context = bpy.context old_layer = context.window.view_layer new_layer = context.scene.view_layers.new(old_layer.name) collection = old_layer.layer_collection new_collection = new_layer.layer_collection for prop in dir(new_layer): try: attr = getattr(old_layer,prop) setattr(new_layer, prop, attr) except: pass cycles = old_layer.cycles new_cycles = new_layer.cycles for prop in dir(new_cycles): try: attr = getattr(cycles,prop) setattr(new_cycles, prop, attr) except: pass def recursive_attributes(collection, new_collection): new_collection.exclude = collection.exclude new_collection.holdout = collection.holdout new_collection.indirect_only = collection.indirect_only new_collection.hide_viewport = collection.hide_viewport for i, _ in enumerate(new_collection.children): old_child = collection.children[i] new_child = new_collection.children[i] recursive_attributes(old_child, new_child) for i, _ in enumerate(new_collection.collection.objects): tmp = collection.collection.objects[i].hide_get() new_collection.collection.objects[i].hide_set(tmp) return 0 recursive_attributes(collection, new_collection) context.window.view_layer = new_layer
thanks for the code, I tried it, and it gave bunch of errors of unexpected indents, and duplicated the view layer, but didn't respect the collections checkmarks, bascially just added a new view layer with copied name of the active layer. :/