gp_render/rn_full_clear.py

39 lines
1008 B
Python

info = {
'icon': 'X',
'description': 'Full Clear : nodes, render_layers, nodegroups',
}
import bpy
C = bpy.context
def clear():
render = bpy.data.scenes.get('Render')
if not render:
print('SKIP, no Render scene')
# # clear passes
# for i in range(len(render.view_layers))[::-1]:
# vl = render.view_layers[i]
# if not ' / ' in vl.name:
# render.view_layers.remove(vl)
# clear all nodes
if render.use_nodes:
for i in range(len(render.node_tree.nodes))[::-1]:
if not render.node_tree.nodes[i].parent:
continue
render.node_tree.nodes.remove(render.node_tree.nodes[i])
# clear all view_layers
for vl in reversed(render.view_layers):
if ' / ' in vl.name:
render.view_layers.remove(vl)
# clear all "NG_" nodegroups
for ng in reversed(bpy.data.node_groups):
if ng.name.startswith('NG_'):
bpy.data.node_groups.remove(ng)
clear()