fixes ui scene settings and clean
0.2.3 - fix: ui errors - fix: scene settings - fix: clean nodesmain
parent
89f48d90f9
commit
d52960acb9
|
@ -9,6 +9,12 @@ OR always duplicate (safe but heavy scenes...)
|
|||
if duplicate, need to "connect" with namespace ('_duprender') or something
|
||||
-->
|
||||
|
||||
0.2.3
|
||||
|
||||
- fix: ui errors
|
||||
- fix: scene settings
|
||||
- fix: clean nodes
|
||||
|
||||
0.2.2
|
||||
|
||||
- feat: quick scene switch with a button in `node_editor > view`
|
||||
|
|
30
OP_clean.py
30
OP_clean.py
|
@ -117,20 +117,24 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
|
|||
|
||||
if self.reorder_inputs:
|
||||
for n in nodes:
|
||||
if n.name.startswith('NG_'):
|
||||
fn.reorder_inputs(n)
|
||||
fn.reorder_outputs(n)
|
||||
if n.type != 'GROUP' or not n.name.startswith('NG_'):
|
||||
continue
|
||||
fn.reorder_inputs(n)
|
||||
fn.reorder_outputs(n)
|
||||
|
||||
# get output node to reorder output
|
||||
out = None
|
||||
for s in n.outputs:
|
||||
if not s.is_linked:
|
||||
continue
|
||||
out = s.links[0].to_node
|
||||
if out.type == 'OUTPUT_FILE':
|
||||
break
|
||||
if out:
|
||||
fn.reorder_fileout(out, ng=n)
|
||||
# get output node to reorder output
|
||||
out = None
|
||||
for s in n.outputs:
|
||||
if not s.is_linked:
|
||||
continue
|
||||
out = s.links[0].to_node
|
||||
if out.type == 'OUTPUT_FILE':
|
||||
break
|
||||
if out:
|
||||
fn.reorder_fileout(out, ng=n)
|
||||
|
||||
# Clear input that do not exists
|
||||
fn.clean_nodegroup_inputs(n, skip_existing_pass=True)
|
||||
|
||||
if self.fo_clear_disconnected:
|
||||
for fo in nodes:
|
||||
|
|
|
@ -2,7 +2,7 @@ bl_info = {
|
|||
"name": "GP exporter",
|
||||
"description": "Organise export of gp layers through compositor output",
|
||||
"author": "Samuel Bernou",
|
||||
"version": (0, 2, 2),
|
||||
"version": (0, 2, 3),
|
||||
"blender": (2, 93, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
|
|
41
fn.py
41
fn.py
|
@ -28,11 +28,34 @@ def new_aa_node(tree):
|
|||
return aa
|
||||
|
||||
|
||||
def copy_settings(obj_a, obj_b):
|
||||
exclusion = ['bl_rna', 'id_data', 'identifier','name_property','rna_type','properties', 'stamp_note_text','use_stamp_note',
|
||||
'settingsFilePath', 'settingsStamp', 'select', 'matrix_local', 'matrix_parent_inverse',
|
||||
'matrix_basis','location','rotation_euler', 'rotation_quaternion', 'rotation_axis_angle', 'scale']
|
||||
|
||||
for attr in dir(obj_a):
|
||||
if attr.startswith('__'):
|
||||
continue
|
||||
if attr in exclusion:
|
||||
continue
|
||||
# print('attr: ', attr)
|
||||
# if obj_a.is_property_readonly(attr): # block when things aren't attribute
|
||||
# continue
|
||||
try:
|
||||
val = getattr(obj_a, attr)
|
||||
except AttributeError:
|
||||
print(f'cant get {attr}')
|
||||
|
||||
try:
|
||||
setattr(obj_b, attr, val)
|
||||
except:
|
||||
print(f"can't set {attr}")
|
||||
|
||||
|
||||
def set_settings(scene=None):
|
||||
if not scene:
|
||||
scene = bpy.context.scene
|
||||
# specify scene settings for these kind of render
|
||||
scene = bpy.context.scene
|
||||
scene.eevee.taa_render_samples = 1
|
||||
scene.grease_pencil_settings.antialias_threshold = 0
|
||||
scene.render.film_transparent = True
|
||||
|
@ -43,12 +66,20 @@ def get_render_scene():
|
|||
'''Get / Create a scene named Render'''
|
||||
render = bpy.data.scenes.get('Render')
|
||||
if not render:
|
||||
current = bpy.context.scene
|
||||
render = bpy.data.scenes.new('Render')
|
||||
## copy original settings over to new scene
|
||||
# copy_settings(current, render) # BAD
|
||||
for attr in ['frame_start', 'frame_end']:
|
||||
setattr(render, attr, getattr(current, attr))
|
||||
copy_settings(current.render, render.render)
|
||||
|
||||
## link cameras (and lights ?)
|
||||
for ob in bpy.context.scene.objects:
|
||||
if ob.type in ('CAMERA', 'LIGHT'):
|
||||
render.collection.objects.link(ob)
|
||||
|
||||
render.camera = current.camera
|
||||
|
||||
# set adapted render settings (no AA)
|
||||
set_settings(render)
|
||||
|
@ -289,12 +320,16 @@ def clear_nodegroup_content_if_disconnected(ngroup):
|
|||
if not connect_to_group_input(n) and not connect_to_group_output(n): # is disconnected from both side
|
||||
ngroup.nodes.remove(n)
|
||||
|
||||
def clean_nodegroup_inputs(ng):
|
||||
def clean_nodegroup_inputs(ng, skip_existing_pass=True):
|
||||
'''Clear inputs to output of passed nodegroup if not connected'''
|
||||
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: # and not any(x.layer == s.name for x in rl_nodes)
|
||||
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
|
||||
continue
|
||||
ngroup.inputs.remove(ngroup.inputs[i])
|
||||
|
||||
# clear_nodegroup_content_if_disconnected(ngroup)
|
||||
|
|
6
ui.py
6
ui.py
|
@ -40,7 +40,11 @@ class GPEXP_PT_gp_node_ui(Panel):
|
|||
|
||||
row = col.row()
|
||||
n = context.scene.node_tree.nodes.active
|
||||
row.enabled = n and n.type == 'R_LAYERS' and not n.outputs[0].is_linked
|
||||
if n:
|
||||
row.enabled = n and n.type == 'R_LAYERS' and not n.outputs[0].is_linked
|
||||
else:
|
||||
row.enabled = False
|
||||
|
||||
row.operator('gp.reconnect_render_layer', icon='ANIM', text='Reconnect')
|
||||
|
||||
col.operator('gp.clean_compo_tree', icon='BRUSHES_ALL', text='Clean Nodes') # NODE_CORNER
|
||||
|
|
Loading…
Reference in New Issue