From f02ab79a0643725d6e090d5b62bc8f384c2aa594 Mon Sep 17 00:00:00 2001 From: Pullusb Date: Thu, 9 Dec 2021 12:14:57 +0100 Subject: [PATCH] clean ops arrange renderlayer nodes 0.7.0 - feat: `clean nodes` ops now rearrange renderlayer nodes within frames --- CHANGELOG.md | 4 ++++ OP_clean.py | 9 ++++++++- __init__.py | 2 +- fn.py | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0411e7e..9eadeb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ Activate / deactivate all masks using MA layers --> +0.7.0 + +- feat: `clean nodes` ops now delete gaps in renderlayer nodes within frames + 0.6.9 - fix: shift correction error diff --git a/OP_clean.py b/OP_clean.py index cc7524f..35be461 100644 --- a/OP_clean.py +++ b/OP_clean.py @@ -61,6 +61,10 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator): description="Delete view layer that aren't used in the nodetree anymore", default=True) + arrange_rl_nodes : bpy.props.BoolProperty(name="Arrange Render Node In Frames", + description="Re-arrange Render Layer Nodes Y positions within each existing frames" , + default=True) + arrange_frames : bpy.props.BoolProperty(name="Arrange Frames", description="Re-arrange all frames Y positions" , default=True) @@ -84,6 +88,7 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator): def draw(self, context): layout = self.layout layout.prop(self, 'clear_unused_view_layers') + layout.prop(self, 'arrange_rl_nodes') layout.prop(self, 'arrange_frames') layout.prop(self, 'reorder_inputs') @@ -112,8 +117,10 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator): continue render.view_layers.remove(rl) + if self.arrange_rl_nodes: + fn.rearrange_rlayers_in_frames(render.node_tree) + if self.arrange_frames: - print('re-arranging frames') fn.rearrange_frames(render.node_tree) if self.reorder_inputs: diff --git a/__init__.py b/__init__.py index 2a47cf7..af50b29 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, 6, 9), + "version": (0, 7, 0), "blender": (2, 93, 0), "location": "View3D", "warning": "", diff --git a/fn.py b/fn.py index 5537c6a..92456e9 100644 --- a/fn.py +++ b/fn.py @@ -341,6 +341,23 @@ def clear_nodegroup(name, full_clear=False): # if full clear bpy.data.node_groups.remove(ng) +def rearrange_rlayers_in_frames(node_tree): + '''rearrange RL nodes in all frames in nodetree''' + frames_l = [n for n in node_tree.nodes if n.type == 'FRAME'] + for f in frames_l: + all_in_frames = [n for n in node_tree.nodes if n.parent == f] + rlayers = [n for n in all_in_frames if n.type == 'R_LAYERS'] + if not rlayers: + continue + all_in_frames.sort(key=lambda x: x.location.y, reverse=True) # descending + rlayers.sort(key=lambda x: x.location.y, reverse=True) # descending + + top = all_in_frames[0].location.y + for rl in rlayers: + # move to top with equal size + rl.location.y = top + top -= rl.dimensions.y + 20 # place next down by height + gap of 20 + def rearrange_frames(node_tree): frame_d = get_frames_bbox(node_tree) # dic : {frame_node:(loc vector, dimensions vector), ...}