connect selection to new or existing fileout
This commit is contained in:
@@ -1787,3 +1787,81 @@ def clean_mats_duplication(ob, skip_different_materials=True):
|
||||
if diff_ct:
|
||||
print(f'{diff_ct} mat skipped >> same name but different color settings!')
|
||||
# return ('INFO', f'{diff_ct} mat skipped >> same name but different color settings!')
|
||||
|
||||
def connect_to_file_output(node_list, file_out=None):
|
||||
scene = bpy.context.scene
|
||||
nodes = scene.node_tree.nodes
|
||||
links = scene.node_tree.links
|
||||
if not isinstance(node_list, list):
|
||||
node_list = [node_list]
|
||||
node_list = [n for n in node_list if n.type != 'OUTPUT_FILE']
|
||||
if not node_list:
|
||||
return
|
||||
|
||||
for node in node_list:
|
||||
## create one output facing node and connect all
|
||||
outs = [o for o in node.outputs if not o.is_unavailable and not 'crypto' in o.name.lower()]
|
||||
cryptout = [o for o in node.outputs if not o.is_unavailable and 'crypto' in o.name.lower()]
|
||||
|
||||
if node.type == 'R_LAYERS':
|
||||
out_base = node.layer
|
||||
elif node.label:
|
||||
out_base = node.label
|
||||
else:
|
||||
out_base = node.name
|
||||
bpy.path.clean_name(out_base)
|
||||
out_name = f'OUT_{out_base}'
|
||||
|
||||
if outs:
|
||||
fo = file_out
|
||||
if not fo:
|
||||
fo = nodes.get(out_name)
|
||||
if not fo:
|
||||
# color = (0.2,0.3,0.5)
|
||||
fo = create_node('CompositorNodeOutputFile', tree=scene.node_tree, location=(real_loc(node)[0]+500, real_loc(node)[1]+50), width=600)
|
||||
set_file_output_format(fo)
|
||||
fo.name = out_name
|
||||
if node.parent:
|
||||
fo.parent = node.parent
|
||||
fo.base_path = f'//render/{out_base}'
|
||||
|
||||
for o in outs:
|
||||
# if o.name == 'Deprecated':
|
||||
# continue
|
||||
slot_name = bpy.path.clean_name(o.name)
|
||||
slot_name = f'{slot_name}/{slot_name}_'
|
||||
fo.file_slots.new(slot_name)
|
||||
out_input = fo.inputs[-1]
|
||||
links.new(o, out_input)
|
||||
clear_disconnected(fo)
|
||||
fo.update()
|
||||
|
||||
## Create separate file out for cryptos
|
||||
if cryptout:
|
||||
out_name += '_cryptos'
|
||||
fo = file_out
|
||||
if not fo:
|
||||
fo = nodes.get(out_name)
|
||||
if not fo:
|
||||
# color = (0.2,0.3,0.5)
|
||||
fo = create_node('CompositorNodeOutputFile', tree=scene.node_tree, location=(real_loc(node)[0]+400, real_loc(node)[1]-200), width=220)
|
||||
set_file_output_format(fo)
|
||||
fo.format.file_format = 'OPEN_EXR_MULTILAYER'
|
||||
fo.format.color_mode = 'RGBA'
|
||||
fo.format.color_depth = '32'
|
||||
fo.format.exr_codec = 'ZIP'
|
||||
fo.name = out_name
|
||||
if node.parent:
|
||||
fo.parent = node.parent
|
||||
fo.base_path = f'//render/{out_base}/cryptos/cryptos_'
|
||||
|
||||
for o in cryptout:
|
||||
slot_name = bpy.path.clean_name(o.name) # directly use name in multi layer exr
|
||||
# slot_name = f'{slot_name}/{slot_name}_'
|
||||
fo.file_slots.new(slot_name)
|
||||
out_input = fo.inputs[-1]
|
||||
links.new(o, out_input)
|
||||
clear_disconnected(fo)
|
||||
fo.update()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user