render checkers and codefix
0.9.4 - feat: `Renumber files on disk` option using number in file outputs (under advanced gp render options) - feat: new `Check for problems` button, check if problem in layer state, missing file out, broken gp modifier target and report - added: clean nodes now also rearrange inside nodegroup - changed: `Check layers` now trigger `export layer infos` automatically. - fix: `export layer infos`: - create render folder if necessary - masks list in json file use name as keys instead of sub-value
This commit is contained in:
@@ -474,16 +474,64 @@ def all_connected_forward(n, nlist=[]):
|
||||
return nlist
|
||||
return nlist + [n]
|
||||
|
||||
def all_connected_forward_from_socket(socket):
|
||||
'''return a list of all nodes connected forward after socket'''
|
||||
node_list = []
|
||||
for ln in socket.links:
|
||||
for n in all_connected_forward(ln.to_node):
|
||||
if n not in node_list:
|
||||
node_list.append(n)
|
||||
# node_list = list(set(node_list))
|
||||
return node_list
|
||||
|
||||
def node_height(n):
|
||||
return n.height if not n.hide else 30
|
||||
|
||||
def reorder_nodegroup_content(ngroup):
|
||||
if isinstance(ngroup, bpy.types.Node):
|
||||
ngroup = ngroup.node_tree
|
||||
|
||||
grp_in = None
|
||||
for n in ngroup.nodes:
|
||||
if n.type == 'GROUP_INPUT':
|
||||
grp_in = n
|
||||
break
|
||||
if not grp_in:
|
||||
return
|
||||
|
||||
n_threads = []
|
||||
for out in grp_in.outputs:
|
||||
n_thread = all_connected_forward_from_socket(out)
|
||||
if n_thread:
|
||||
n_threads.append(n_thread)
|
||||
|
||||
level = grp_in.location.y
|
||||
for thread in n_threads:
|
||||
top = max([n.location.y for n in thread])
|
||||
bottom = min([n.location.y - node_height(n) for n in thread])
|
||||
thread_h = top - bottom
|
||||
# move all nodes to adjust to level
|
||||
diff_to_add = level - top
|
||||
for n in thread:
|
||||
n.location.y += diff_to_add
|
||||
# move level to bottom
|
||||
level -= thread_h + 2 # add a gap of two
|
||||
|
||||
def clear_nodegroup_content_if_disconnected(ngroup):
|
||||
'''Get a nodegroup.node_tree
|
||||
delete orphan nodes that are not connected from group input node
|
||||
'''
|
||||
if isinstance(ngroup, bpy.types.Node):
|
||||
# case where a node is sent instead of the group
|
||||
ngroup = ngroup.node_tree
|
||||
|
||||
for n in reversed(ngroup.nodes):
|
||||
if n.type in ('GROUP_INPUT', 'GROUP_OUTPUT'):
|
||||
continue
|
||||
if not connect_to_group_input(n) and not connect_to_group_output(n): # is disconnected from both side
|
||||
ngroup.nodes.remove(n)
|
||||
|
||||
reorder_nodegroup_content(ngroup)
|
||||
|
||||
def clean_nodegroup_inputs(ng, skip_existing_pass=True):
|
||||
'''Clear inputs to output of passed nodegroup if not connected'''
|
||||
|
||||
Reference in New Issue
Block a user