Basically I’m writing an Addon that changes the materials of objects when switching ViewLayers. This already works when switching viewlayers in the UI (via msgbus):
def on_view_layer_changed(): ng = bpy.data.node_groups["lt switch"] ng.links.new(ng.nodes["Group Input"].outputs[bpy.context.view_layer.name], ng.nodes["Group Output"].inputs) print(bpy.context.view_layer.name) def subscribe(): bpy.msgbus.subscribe_rna( key=(bpy.types.Window, "view_layer"), owner=bpy, args=(), # Optional arguments notify=on_view_layer_changed)
But of course this doesn’t work when I hit render and all viewlayers are rendered. I need to be able to run code inbetween the individual viewlayer renderings. Does anyone have an Idea how to do this?
what it does: