parent
d52960acb9
commit
a3ab7644a7
|
@ -9,6 +9,11 @@ OR always duplicate (safe but heavy scenes...)
|
|||
if duplicate, need to "connect" with namespace ('_duprender') or something
|
||||
-->
|
||||
|
||||
0.2.4
|
||||
|
||||
- fix: scene world transfer
|
||||
- code: remove prints
|
||||
|
||||
0.2.3
|
||||
|
||||
- fix: ui errors
|
||||
|
|
|
@ -68,7 +68,7 @@ def merge_layers(rlayers, obname=None, active=None, disconnect=True):
|
|||
ng_name += '_02' # if not ending with a number add _02
|
||||
ng_name = re.sub(r'(\d+)(?!.*\d)', lambda x: str(int(x.group(1))+1).zfill(len(x.group(1))), ng_name)
|
||||
|
||||
print(f'create merge nodegroup {ng_name}')
|
||||
# print(f'create merge nodegroup {ng_name}')
|
||||
ngroup = bpy.data.node_groups.new(ng_name, 'CompositorNodeTree')
|
||||
ng = fn.create_node('CompositorNodeGroup', tree=node_tree, location=(fn.real_loc(rlayers[0]).x + 1900, fn.real_loc(rlayers[0]).y - 200), width=400)
|
||||
ng.node_tree = ngroup
|
||||
|
@ -121,11 +121,10 @@ class GPEXP_OT_merge_selected_dopesheet_layers(bpy.types.Operator):
|
|||
# merge_selected_layers() # function to merge from GP dopesheet
|
||||
ob = bpy.context.object
|
||||
layer_names = [l.info for l in ob.data.layers if l.select and not l.hide]
|
||||
print("layer_names", layer_names)#Dbg
|
||||
|
||||
if len(layer_names) < 2:
|
||||
print(f'Should select multiple layers for merging')
|
||||
return
|
||||
self.report({'ERROR'}, f'Should select multiple layers for merging')
|
||||
return {"CANCELLED"}
|
||||
|
||||
render = bpy.data.scenes.get('Render')
|
||||
if render:
|
||||
|
@ -163,8 +162,8 @@ class GPEXP_OT_merge_selected_viewlayer_nodes(bpy.types.Operator):
|
|||
def execute(self, context):
|
||||
render = bpy.data.scenes.get('Render')
|
||||
if not render:
|
||||
print('No render scene')
|
||||
return
|
||||
self.report({'ERROR'}, 'No render scene')
|
||||
return {"CANCELLED"}
|
||||
|
||||
nodes = render.node_tree.nodes
|
||||
selection = [n for n in nodes if n.select and n.type == 'R_LAYERS']
|
||||
|
@ -175,7 +174,7 @@ class GPEXP_OT_merge_selected_viewlayer_nodes(bpy.types.Operator):
|
|||
|
||||
# should be from the same object:
|
||||
if not all(selection[0].layer.split('.')[0] == n.layer.split('.')[0] for n in selection):
|
||||
print('Merge -> Not every nodes start with the same object')
|
||||
print('/!\ Merge -> Not every nodes start with the same object')
|
||||
|
||||
# obname = selection[0].layer.split('.')[0]
|
||||
merge_layers(selection, active=nodes.active, disconnect=self.disconnect)
|
||||
|
|
|
@ -31,7 +31,7 @@ class GPEXP_OT_number_outputs(bpy.types.Operator):
|
|||
continue
|
||||
if self.mode == 'SELECTED' and not fo.select:
|
||||
continue
|
||||
print(f'numbering {fo.name}')
|
||||
# print(f'numbering {fo.name}')
|
||||
ct += 1
|
||||
if self.ctrl:
|
||||
fn.delete_numbering(fo)
|
||||
|
|
23
fn.py
23
fn.py
|
@ -44,12 +44,14 @@ def copy_settings(obj_a, obj_b):
|
|||
try:
|
||||
val = getattr(obj_a, attr)
|
||||
except AttributeError:
|
||||
print(f'cant get {attr}')
|
||||
# print(f'cant get {attr}')
|
||||
pass
|
||||
|
||||
try:
|
||||
setattr(obj_b, attr, val)
|
||||
except:
|
||||
print(f"can't set {attr}")
|
||||
# print(f"can't set {attr}")
|
||||
pass
|
||||
|
||||
|
||||
def set_settings(scene=None):
|
||||
|
@ -79,7 +81,9 @@ def get_render_scene():
|
|||
if ob.type in ('CAMERA', 'LIGHT'):
|
||||
render.collection.objects.link(ob)
|
||||
|
||||
# use same cam and world
|
||||
render.camera = current.camera
|
||||
render.world = current.world
|
||||
|
||||
# set adapted render settings (no AA)
|
||||
set_settings(render)
|
||||
|
@ -220,7 +224,8 @@ def rearrange_frames(node_tree):
|
|||
print('no frame found')
|
||||
return
|
||||
|
||||
print([f.name for f in frame_d.keys()])
|
||||
# print([f.name for f in frame_d.keys()])
|
||||
|
||||
## order the dict by frame.y location
|
||||
frame_d = {key: value for key, value in sorted(frame_d.items(), key=lambda pair: pair[1][0].y - pair[1][1].y, reverse=True)}
|
||||
frames = [[f, v[0], v[1].y] for f, v in frame_d.items()] # [frame_node, real_loc, real dimensions]
|
||||
|
@ -325,7 +330,6 @@ def clean_nodegroup_inputs(ng, skip_existing_pass=True):
|
|||
ngroup = ng.node_tree
|
||||
rl_nodes = [n.layer for n in ng.id_data.nodes if n.type == 'R_LAYERS']
|
||||
for i in range(len(ng.inputs))[::-1]:
|
||||
print(i)
|
||||
if not ng.inputs[i].is_linked:
|
||||
if skip_existing_pass and any(ng.inputs[i].name == x for x in rl_nodes):
|
||||
# a render layer of this name still exists
|
||||
|
@ -446,11 +450,9 @@ def renumber_keep_existing(fo, offset=10):
|
|||
prev = None
|
||||
prev_num = None
|
||||
for idx, fs in enumerate(fsl):
|
||||
print('-->', idx, fs.path)
|
||||
# print('-->', idx, fs.path)
|
||||
|
||||
if idx == last_idx: # handle last
|
||||
print('last >>', fs.path)
|
||||
print(ct)
|
||||
if idx > 0:
|
||||
prev = fsl[idx-1]
|
||||
num = get_num(prev)
|
||||
|
@ -471,11 +473,9 @@ def renumber_keep_existing(fo, offset=10):
|
|||
|
||||
# analyse all next slots until there is numbered
|
||||
divider = 0
|
||||
print(f'range(1, {len(fsl) - idx}')
|
||||
# print(f'range(1, {len(fsl) - idx}')
|
||||
for i in range(1, len(fsl) - idx):
|
||||
print('i >> idx + i', i, idx + i)
|
||||
next_num = get_num(fsl[idx + i])
|
||||
print('next_num: ', next_num)
|
||||
if next_num is not None:
|
||||
divider = i+1
|
||||
break
|
||||
|
@ -503,12 +503,9 @@ def renumber_keep_existing(fo, offset=10):
|
|||
add_fileslot_number(fs, ct)
|
||||
|
||||
else:
|
||||
print('divider: ', divider)
|
||||
if prev_num is not None:
|
||||
print('in updater')
|
||||
# iterate rename
|
||||
gap_inc = int((next_num - prev_num) / divider)
|
||||
print('gap_inc: ', gap_inc)
|
||||
if gap_inc < 1: # same values !
|
||||
print(f'cannot insert a median value at {fs.path} between {prev_num} and {next_num}')
|
||||
continue
|
||||
|
|
|
@ -94,7 +94,6 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
|||
ng_out = fn.create_node('NodeGroupOutput', tree=ngroup, location=(600,0))
|
||||
|
||||
else:
|
||||
print(f'found group node {ng.name}')
|
||||
ngroup = ng.node_tree
|
||||
ng_in = ngroup.nodes.get('Group Input')
|
||||
ng_out = ngroup.nodes.get('Group Output')
|
||||
|
@ -103,14 +102,13 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
|||
if not rlayer.outputs['Image'].is_linked:
|
||||
sockin = ng.inputs.get(vl_name)
|
||||
if not sockin:
|
||||
print('creating socket', vl_name)
|
||||
sockin = ng.inputs.new('NodeSocketColor', vl_name)
|
||||
sockin = ng.inputs[-1]
|
||||
|
||||
links.new(rlayer.outputs['Image'], sockin)
|
||||
|
||||
## get nodes from frame
|
||||
rl_nodes = [n for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer' and n.parent == frame]
|
||||
# rl_nodes = [n for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer' and n.parent == frame]
|
||||
|
||||
# auto clean : if an input exists but is not linked and name not exists in rlayers of current frame
|
||||
for s in reversed(ng.inputs):
|
||||
|
@ -138,16 +136,14 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
|||
ng.update()
|
||||
|
||||
if not connected:
|
||||
print('need to connect')
|
||||
# add AA and connect
|
||||
aa = fn.new_aa_node(ngroup)
|
||||
groupout = ng.outputs.get(vl_name)
|
||||
if not groupout:
|
||||
print('create group out-socket')
|
||||
ng.outputs.new('NodeSocketColor', vl_name) # assigning direcly doesn't link well
|
||||
groupout = ng.outputs[-1]
|
||||
|
||||
print('ng_out.inputs.get(vl_name): ', ng_out.inputs.get(vl_name))
|
||||
# print('ng_out.inputs.get(vl_name): ', ng_out.inputs.get(vl_name))
|
||||
# ng_in.outputs[vl_name]
|
||||
ngroup.links.new(ng_in.outputs[vl_name], aa.inputs[0]) # node_tree
|
||||
ngroup.links.new(aa.outputs[0], ng_out.inputs[vl_name]) # node_tree
|
||||
|
@ -197,7 +193,7 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
|||
if not out_input:
|
||||
out.file_slots.new(slot_name)
|
||||
out_input = out.inputs[-1] # assigning directly above doesn't link afterwards
|
||||
print(f'new filouput entry: {out_input}')
|
||||
# print(f'new filouput entry: {out_input}')
|
||||
|
||||
# link to FileOut
|
||||
links.new(groupout, out_input)
|
||||
|
@ -221,7 +217,9 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
|||
|
||||
in_rds = scene.collection.all_objects.get(ob.name)
|
||||
if not in_rds:
|
||||
# TODO : link with a ob.data copy if its a multiuser object !
|
||||
scene.collection.objects.link(ob)
|
||||
ob.hide_viewport = ob.hide_render = False
|
||||
|
||||
# create viewlayer
|
||||
vl_name = f'{ob.name} / {l.info}'
|
||||
|
@ -239,10 +237,10 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
|||
for f in nodes if f.type == 'FRAME'}
|
||||
|
||||
# debug print
|
||||
for k,v in frame_dic.items():
|
||||
print('-', k)
|
||||
for n in v:
|
||||
print('---', n.layer)
|
||||
# for k,v in frame_dic.items():
|
||||
# print('-', k)
|
||||
# for n in v:
|
||||
# print('---', n.layer)
|
||||
|
||||
if rlayer_list: # rlayer exists
|
||||
print(f'{len(rlayer_list)} nodes using {vl_name}')
|
||||
|
@ -268,16 +266,13 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
|||
all_frames = [n for n in nodes if n.type == 'FRAME']
|
||||
# all_rl_x = [n.location.x for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer']
|
||||
if all_frames:
|
||||
print
|
||||
# all_frames.sort(key=lambda x: x.location.y, reverse=True)
|
||||
# loc.y - dim.y
|
||||
y_loc = min(fn.get_frame_transform(f, node_tree)[0].y - fn.get_frame_transform(f, node_tree)[1].y for f in all_frames)
|
||||
print('y_loc: ', y_loc)
|
||||
loc = (0, y_loc)
|
||||
else:
|
||||
loc = (0,0)
|
||||
|
||||
print('loc: ', loc)
|
||||
# create frame at new rl position
|
||||
frame = nodes.new('NodeFrame')
|
||||
frame.label = ob.name
|
||||
|
@ -309,7 +304,6 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
|||
# get nodes order to insert
|
||||
rl_nodes.sort(key=lambda n: fn.real_loc(n).y, reverse=True) # descending
|
||||
top_loc = fn.real_loc(rl_nodes[0])
|
||||
print('top_loc: ', top_loc)
|
||||
else:
|
||||
top_loc = fn.get_frame_transform(frame[1], node_tree) - 60
|
||||
|
||||
|
@ -327,10 +321,10 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
|||
rl_nodes.sort(key=lambda x : names.index(x.layer.split(' / ')[1])) # Sort True layer name from rl
|
||||
|
||||
offset = 0
|
||||
print(f'number of nodes in frame: {len(rl_nodes)}')
|
||||
# print(f'number of nodes in frame: {len(rl_nodes)}')
|
||||
ref_node = rl_nodes[0]
|
||||
|
||||
print('ref_node: ', ref_node.name, ref_node.location)
|
||||
# print('ref_node: ', ref_node.name, ref_node.location)
|
||||
for n in rl_nodes:
|
||||
# set x loc from first node in list (maybe use leftmost ?)
|
||||
n.location = Vector((fn.real_loc(ref_node)[0], top_loc[1] - offset)) - n.parent.location
|
||||
|
|
|
@ -424,7 +424,7 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
|||
if not out_input:
|
||||
out.file_slots.new(slot_name)
|
||||
out_input = out.inputs[-1] # assigning directly above doesn't link afterwards
|
||||
print(f'new filouput entry: {out_input}')
|
||||
# print(f'new filouput entry: {out_input}')
|
||||
|
||||
# link to FileOut
|
||||
links.new(groupout, out_input)
|
||||
|
|
Loading…
Reference in New Issue