clean ops arrange renderlayer nodes

0.7.0

- feat: `clean nodes` ops now rearrange renderlayer nodes within frames
main
Pullusb 2021-12-09 12:14:57 +01:00
parent 75a26fa4b6
commit f02ab79a06
4 changed files with 30 additions and 2 deletions

View File

@ -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 0.6.9
- fix: shift correction error - fix: shift correction error

View File

@ -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", description="Delete view layer that aren't used in the nodetree anymore",
default=True) 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", arrange_frames : bpy.props.BoolProperty(name="Arrange Frames",
description="Re-arrange all frames Y positions" , description="Re-arrange all frames Y positions" ,
default=True) default=True)
@ -84,6 +88,7 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.prop(self, 'clear_unused_view_layers') layout.prop(self, 'clear_unused_view_layers')
layout.prop(self, 'arrange_rl_nodes')
layout.prop(self, 'arrange_frames') layout.prop(self, 'arrange_frames')
layout.prop(self, 'reorder_inputs') layout.prop(self, 'reorder_inputs')
@ -112,8 +117,10 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
continue continue
render.view_layers.remove(rl) render.view_layers.remove(rl)
if self.arrange_rl_nodes:
fn.rearrange_rlayers_in_frames(render.node_tree)
if self.arrange_frames: if self.arrange_frames:
print('re-arranging frames')
fn.rearrange_frames(render.node_tree) fn.rearrange_frames(render.node_tree)
if self.reorder_inputs: if self.reorder_inputs:

View File

@ -2,7 +2,7 @@ bl_info = {
"name": "GP Render", "name": "GP Render",
"description": "Organise export of gp layers through compositor output", "description": "Organise export of gp layers through compositor output",
"author": "Samuel Bernou", "author": "Samuel Bernou",
"version": (0, 6, 9), "version": (0, 7, 0),
"blender": (2, 93, 0), "blender": (2, 93, 0),
"location": "View3D", "location": "View3D",
"warning": "", "warning": "",

17
fn.py
View File

@ -341,6 +341,23 @@ def clear_nodegroup(name, full_clear=False):
# if full clear # if full clear
bpy.data.node_groups.remove(ng) 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): def rearrange_frames(node_tree):
frame_d = get_frames_bbox(node_tree) # dic : {frame_node:(loc vector, dimensions vector), ...} frame_d = get_frames_bbox(node_tree) # dic : {frame_node:(loc vector, dimensions vector), ...}