From 556f767f3b1a398604c2e60dbe90aade75c13429 Mon Sep 17 00:00:00 2001 From: pullusb Date: Tue, 4 Apr 2023 15:51:41 +0200 Subject: [PATCH] compatibility with newer Blender 1.3.2 - fixed: compatibility with blender 3.5 (nodegroup socket API change) --- CHANGELOG.md | 4 ++++ OP_merge_layers.py | 8 +++++--- __init__.py | 2 +- fn.py | 24 +++++++++++++++++------- gen_vlayer.py | 3 ++- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d049097..8df7bbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Activate / deactivate layer opacity according to prefix Activate / deactivate all masks using MA layers --> +1.3.2 + +- fixed: compatibility with blender 3.5 (nodegroup socket API change) + 1.3.1 - added: preview generation in autobuild diff --git a/OP_merge_layers.py b/OP_merge_layers.py index 7c60bd5..52628e2 100644 --- a/OP_merge_layers.py +++ b/OP_merge_layers.py @@ -206,15 +206,17 @@ def merge_compositor_preview(scene=None, clear=False): ng['is_preview'] = 1 fn.create_node('NodeGroupInput', tree=ngroup, location=(-600,0)) fn.create_node('NodeGroupOutput', tree=ngroup, location=(1000,0)) + ## ngroup.outputs.new('NodeSocketColor', 'Image') # generated in merge_inputs # Create inputs and links to node_group for rln in comp_list: - rln.outputs['Image'] - sockin = ng.inputs.new('NodeSocketColor', rln.layer) + sockin = ng.node_tree.inputs.new('NodeSocketColor', rln.layer) sockin = ng.inputs[-1] + # sockin = ng.inputs.new('NodeSocketColor', rln.layer) + # sockin = ng.inputs[-1] links.new(rln.outputs['Image'], sockin) - fn.nodegroup_merge_inputs(ng.node_tree) + fn.nodegroup_merge_inputs(ng.node_tree, aa=False) # do not create AA node (needed ?) ng.update() # Create composite out (if needed) and connect diff --git a/__init__.py b/__init__.py index 2e9a8a4..f83ffe4 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": (1, 3, 1), + "version": (1, 3, 2), "blender": (2, 93, 0), "location": "View3D", "warning": "", diff --git a/fn.py b/fn.py index 85514d5..4278080 100644 --- a/fn.py +++ b/fn.py @@ -63,6 +63,10 @@ def create_aa_nodegroup(tree): sep = create_node('CompositorNodeSepRGBA', tree=ngroup, location=(-150,0)) comb = create_node('CompositorNodeCombRGBA', tree=ngroup, location=(350,25)) + # if bpy.app.version >= (3,4,0): + ngroup.inputs.new('NodeSocketColor', 'Image') + ngroup.outputs.new('NodeSocketColor', 'Image') + # in AA # ngroup.links.new(comb.outputs[0], ng_out.inputs[0]) # <- connect without out AA aa = new_aa_node(ngroup, location=(-400, 0)) @@ -771,7 +775,7 @@ def random_color(alpha=False): return (random.uniform(0,1), random.uniform(0,1), random.uniform(0,1), 1) return (random.uniform(0,1), random.uniform(0,1), random.uniform(0,1)) -def nodegroup_merge_inputs(ngroup): +def nodegroup_merge_inputs(ngroup, aa=True): '''Get a nodegroup merge every group inputs with alpha over then connect to antialias and a new output @@ -801,14 +805,20 @@ def nodegroup_merge_inputs(ngroup): y += offset_y prev = ao - ## create a merged name as output ?? - aa = create_aa_nodegroup(ngroup) # new_aa_node(ngroup) - aa.location = (ao.location.x + 200, ao.location.y) - ngroup.links.new(ao.outputs[0], aa.inputs[0]) # node_tree - # create one input and link out = ngroup.outputs.new('NodeSocketColor', ngroup.inputs[0].name) - ngroup.links.new(aa.outputs[0], ng_out.inputs[0]) + + ## create a merged name as output ?? + if aa: + # create AA and link + aa = create_aa_nodegroup(ngroup) # new_aa_node(ngroup) + aa.location = (ao.location.x + 200, ao.location.y) + ngroup.links.new(ao.outputs[0], aa.inputs[0]) # node_tree + ngroup.links.new(aa.outputs[0], ng_out.inputs[0]) + else: + # link directly + ngroup.links.new(ao.outputs[0], ng_out.inputs[0]) + ## -- renumbering funcs diff --git a/gen_vlayer.py b/gen_vlayer.py index c3b0f20..92a5b3e 100644 --- a/gen_vlayer.py +++ b/gen_vlayer.py @@ -118,7 +118,8 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None): for s in reversed(ng.inputs): if not s.is_linked: # and not any(x.layer == s.name for x in rl_nodes) print(f'removing grp unlinked input {s.name}') - ng.inputs.remove(s) + # ng.inputs.remove(s) + ng.node_tree.inputs.remove(s) ## get nodes from linked NG inputs ??? maybe more clear... # rl_nodes = [s.links[0].from_node for s in ng.inputs if s.links and s.links[0].from_node and s.links[0].from_node.type == 'R_LAYERS']