39 lines
955 B
Python
39 lines
955 B
Python
info = {
|
|
'icon': 'X',
|
|
'description': 'Clear',
|
|
}
|
|
|
|
import bpy
|
|
C = bpy.context
|
|
|
|
# clear passes
|
|
for i in range(len(C.scene.view_layers))[::-1]:
|
|
vl = C.scene.view_layers[i]
|
|
if not vl.name.startswith('View'):
|
|
C.scene.view_layers.remove(vl)
|
|
|
|
|
|
# clear nodes
|
|
if C.scene.use_nodes:
|
|
for n in range(len(C.scene.node_tree.nodes))[::-1]:
|
|
C.scene.node_tree.nodes.remove(C.scene.node_tree.nodes[i])
|
|
|
|
|
|
def get_cols(c, cols=[]):
|
|
'''recursively get all collection in passed collection'''
|
|
for child in c.children:
|
|
cols.append(child)
|
|
get_cols(child, cols)
|
|
return cols
|
|
|
|
# delete OUTPOUT collection
|
|
out = bpy.data.collections.get('OUTPUT')
|
|
if out:
|
|
for o in [o for o in out.all_objects][::-1]:
|
|
bpy.data.objects.remove(o)
|
|
|
|
col_list = get_cols(out)
|
|
print("col_list", [c.name for c in col_list])#Dbg
|
|
for c in col_list:
|
|
bpy.data.collections.remove(c)
|
|
bpy.data.collections.remove(out) |