diff --git a/CHANGELOG.md b/CHANGELOG.md index d81d765..a77256b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Activate / deactivate layer opaticty according to prefix Activate / deactivate all masks using MA layers --> +0.5.1 + +- feat: reconnect existing sockets inside nodegroups with clean nodes > re-order + 0.5.0 - feat: add a render operator that render all scene diff --git a/OP_clean.py b/OP_clean.py index d509657..cc7524f 100644 --- a/OP_clean.py +++ b/OP_clean.py @@ -136,6 +136,8 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator): # Clear input that do not exists fn.clean_nodegroup_inputs(n, skip_existing_pass=True) + + fn.bridge_reconnect_nodegroup(n) if self.fo_clear_disconnected: for fo in nodes: @@ -143,7 +145,6 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator): continue fn.clear_disconnected(fo) - return {"FINISHED"} diff --git a/__init__.py b/__init__.py index b948669..aedc594 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ bl_info = { "name": "GP Render", "description": "Organise export of gp layers through compositor output", "author": "Samuel Bernou", - "version": (0, 5, 0), + "version": (0, 5, 1), "blender": (2, 93, 0), "location": "View3D", "warning": "", diff --git a/fn.py b/fn.py index ff770a3..7f0109f 100644 --- a/fn.py +++ b/fn.py @@ -447,6 +447,31 @@ def clean_nodegroup_inputs(ng, skip_existing_pass=True): # clear_nodegroup_content_if_disconnected(ngroup) +def bridge_reconnect_nodegroup(ng, socket_name=None): + ''' + Reconnect group_in and group out that have been disconnected + :socket: only use this specific socket type + ''' + ngroup = ng.node_tree + ng_in = ngroup.nodes.get('Group Input') + ng_out = ngroup.nodes.get('Group Output') + for sockin in ng_in.outputs: + if socket_name and sockin.name != socket_name: + continue + if not sockin.name: # last empty output is listed + continue + sockout = ng_out.inputs.get(sockin.name) + if not sockout: + continue + if len(sockin.links) and connect_to_group_output(sockin.links[0].to_node): + continue + ## need reconnect + aa = create_aa_nodegroup(ngroup) + ngroup.links.new(sockin, aa.inputs[0]) + ngroup.links.new(aa.outputs[0], sockout) + print(f'{ng.name}: Bridged {sockin.name}') + + def random_color(alpha=False): import random if alpha: