fix merge function for blender4

main
pullusb 2024-01-16 13:56:18 +01:00
parent 74d94e2cdb
commit a6e8da6973
1 changed files with 21 additions and 8 deletions

29
fn.py
View File

@ -447,15 +447,28 @@ def remove_nodes_by_viewlayer(viewlayer_list, scene=None):
# remove input and output from group # remove input and output from group
# grp.inputs.remove(sockin) # do not clear inside !! # grp.inputs.remove(sockin) # do not clear inside !!
# grp.outputs.remove(sockout) # do not clear inside !! # grp.outputs.remove(sockout) # do not clear inside !!
ngroup = grp.node_tree ngroup = grp.node_tree
for i in range(len(grp.inputs))[::-1]: if bpy.app.version < (4,0,0):
if grp.inputs[i].name == sockin.name: for i in range(len(grp.inputs))[::-1]:
ngroup.inputs.remove(ngroup.inputs[i]) if grp.inputs[i].name == sockin.name:
break ngroup.inputs.remove(ngroup.inputs[i])
for i in range(len(grp.outputs))[::-1]: break
if grp.outputs[i].name == sockout.name: for i in range(len(grp.outputs))[::-1]:
ngroup.outputs.remove(ngroup.outputs[i]) if grp.outputs[i].name == sockout.name:
break ngroup.outputs.remove(ngroup.outputs[i])
break
else:
g_inputs = [s for s in ngroup.interface.items_tree if s.in_out == 'INPUT']
g_outputs = [s for s in ngroup.interface.items_tree if s.in_out == 'OUTPUT']
for i in range(len(grp.inputs))[::-1]:
if grp.inputs[i].name == sockin.name:
ngroup.interface.remove(g_inputs[i])
break
for i in range(len(grp.outputs))[::-1]:
if grp.outputs[i].name == sockout.name:
ngroup.interface.remove(g_outputs[i])
break
# Remove render_layer node # Remove render_layer node
scene.node_tree.nodes.remove(n) scene.node_tree.nodes.remove(n)