code render scene comments cleanup
parent
4618982a37
commit
abc93bc1f9
49
OP_clean.py
49
OP_clean.py
|
@ -1,55 +1,6 @@
|
||||||
import bpy
|
import bpy
|
||||||
from . import fn
|
from . import fn
|
||||||
|
|
||||||
## direct use (Pop up menu version below)
|
|
||||||
"""
|
|
||||||
class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
|
|
||||||
bl_idname = "gp.clean_compo_tree"
|
|
||||||
bl_label = "Clean Compo Tree"
|
|
||||||
bl_description = "Reorder inputs/outputs and clear unused viewlayers"
|
|
||||||
bl_options = {"REGISTER"}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return True
|
|
||||||
|
|
||||||
# mode : bpy.props.StringProperty(default='NORMAL', options={'SKIP_SAVE'})
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
render = bpy.data.scenes.get('Render')
|
|
||||||
if not render:
|
|
||||||
print('SKIP, no Render scene')
|
|
||||||
return {"CANCELLED"}
|
|
||||||
|
|
||||||
print('re-arranging frames')
|
|
||||||
fn.rearrange_frames(render.node_tree)
|
|
||||||
|
|
||||||
for n in render.node_tree.nodes:
|
|
||||||
if n.name.startswith('NG_'):
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
## clear disconnected fileout ??...
|
|
||||||
# for fo in render.node_tree.nodes:
|
|
||||||
# if fo.type != 'OUTPUT_FILE':
|
|
||||||
# continue
|
|
||||||
# fn.clear_disconnected(fo)
|
|
||||||
|
|
||||||
return {"FINISHED"}
|
|
||||||
"""
|
|
||||||
|
|
||||||
class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
|
class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
|
||||||
bl_idname = "gp.clean_compo_tree"
|
bl_idname = "gp.clean_compo_tree"
|
||||||
bl_label = "Clean Compo Tree"
|
bl_label = "Clean Compo Tree"
|
||||||
|
|
|
@ -11,7 +11,6 @@ class GPEXP_OT_mute_toggle_output_nodes(bpy.types.Operator):
|
||||||
mute : bpy.props.BoolProperty(default=True, options={'SKIP_SAVE'})
|
mute : bpy.props.BoolProperty(default=True, options={'SKIP_SAVE'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# scene = bpy.data.scenes.get('Render')
|
|
||||||
ct = 0
|
ct = 0
|
||||||
for n in context.scene.node_tree.nodes:
|
for n in context.scene.node_tree.nodes:
|
||||||
if n.type != 'OUTPUT_FILE':
|
if n.type != 'OUTPUT_FILE':
|
||||||
|
@ -45,10 +44,6 @@ class GPEXP_OT_number_outputs(bpy.types.Operator):
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
# scn = bpy.data.scenes.get('Render')
|
|
||||||
# if not scn:
|
|
||||||
# print('SKIP, no Render scene')
|
|
||||||
# return {"CANCELLED"}
|
|
||||||
|
|
||||||
ct = 0
|
ct = 0
|
||||||
nodes = scn.node_tree.nodes
|
nodes = scn.node_tree.nodes
|
||||||
|
@ -63,7 +58,6 @@ class GPEXP_OT_number_outputs(bpy.types.Operator):
|
||||||
fn.delete_numbering(fo)
|
fn.delete_numbering(fo)
|
||||||
else:
|
else:
|
||||||
fn.renumber_keep_existing(fo)
|
fn.renumber_keep_existing(fo)
|
||||||
# fn.renumber(fo)
|
|
||||||
|
|
||||||
txt = 'de-numbered' if self.clear else 're-numbered'
|
txt = 'de-numbered' if self.clear else 're-numbered'
|
||||||
if ct:
|
if ct:
|
||||||
|
@ -82,7 +76,6 @@ class GPEXP_OT_set_output_node_format(bpy.types.Operator):
|
||||||
mute : bpy.props.BoolProperty(default=True, options={'SKIP_SAVE'})
|
mute : bpy.props.BoolProperty(default=True, options={'SKIP_SAVE'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# scene = bpy.data.scenes.get('Render')
|
|
||||||
nodes = context.scene.node_tree.nodes
|
nodes = context.scene.node_tree.nodes
|
||||||
if not nodes.active or nodes.active.type != 'OUTPUT_FILE':
|
if not nodes.active or nodes.active.type != 'OUTPUT_FILE':
|
||||||
self.report({"ERROR"}, f'Active node should be an output file to use as reference for output format')
|
self.report({"ERROR"}, f'Active node should be an output file to use as reference for output format')
|
||||||
|
@ -140,11 +133,7 @@ class GPEXP_OT_normalize_outnames(bpy.types.Operator):
|
||||||
mute : bpy.props.BoolProperty(default=True, options={'SKIP_SAVE'})
|
mute : bpy.props.BoolProperty(default=True, options={'SKIP_SAVE'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# scene = bpy.data.scenes.get('Render')
|
|
||||||
nodes = context.scene.node_tree.nodes
|
nodes = context.scene.node_tree.nodes
|
||||||
# if not nodes.active or nodes.active.type != 'OUTPUT_FILE':
|
|
||||||
# self.report({"ERROR"}, f'')
|
|
||||||
# return {"CANCELLED"}
|
|
||||||
|
|
||||||
reslash = re.compile('\\/')
|
reslash = re.compile('\\/')
|
||||||
ct = 0
|
ct = 0
|
||||||
|
@ -178,10 +167,6 @@ class GPEXP_OT_enable_all_viewlayers(bpy.types.Operator):
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# scn = bpy.data.scenes.get('Render')
|
|
||||||
# if not scn:
|
|
||||||
# print('SKIP, no Render scene')
|
|
||||||
# return {"CANCELLED"}
|
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
|
|
||||||
vl_list = [vl for vl in scn.view_layers if not vl.use and vl.name not in {'View Layer', 'exclude'}]
|
vl_list = [vl for vl in scn.view_layers if not vl.use and vl.name not in {'View Layer', 'exclude'}]
|
||||||
|
@ -198,10 +183,6 @@ class GPEXP_OT_activate_only_selected_layers(bpy.types.Operator):
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# scn = bpy.data.scenes.get('Render')
|
|
||||||
# if not scn:
|
|
||||||
# print('SKIP, no Render scene')
|
|
||||||
# return {"CANCELLED"}
|
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
|
|
||||||
nodes = scn.node_tree.nodes
|
nodes = scn.node_tree.nodes
|
||||||
|
|
|
@ -260,12 +260,6 @@ class GPEXP_OT_merge_viewlayers_to_active(bpy.types.Operator):
|
||||||
else:
|
else:
|
||||||
layers = [l for l in ob.data.layers if l.select and l != act]
|
layers = [l for l in ob.data.layers if l.select and l != act]
|
||||||
|
|
||||||
## Tested in func
|
|
||||||
# rd_scn = bpy.data.scenes.get('Render')
|
|
||||||
# if not rd_scn:
|
|
||||||
# self.report({'ERROR'}, 'Viewlayers needs to be generated first!')
|
|
||||||
# return {'CANCELLED'}
|
|
||||||
|
|
||||||
# if not act.viewlayer_render:
|
# if not act.viewlayer_render:
|
||||||
# self.report({'ERROR'}, f'Active layer {act.info} has no viewlayer assigned')
|
# self.report({'ERROR'}, f'Active layer {act.info} has no viewlayer assigned')
|
||||||
# return {'CANCELLED'}
|
# return {'CANCELLED'}
|
||||||
|
@ -308,12 +302,7 @@ class GPEXP_OT_remove_viewlayer_on_selected(bpy.types.Operator):
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
ob = context.object
|
ob = context.object
|
||||||
|
|
||||||
## Force use of render scene (?)
|
scn = context.scene
|
||||||
rd_scn = context.scene
|
|
||||||
# rd_scn = bpy.data.scenes.get('Render')
|
|
||||||
# if not rd_scn:
|
|
||||||
# self.report({'ERROR'}, 'No render scene found')
|
|
||||||
# return {'CANCELLED'}
|
|
||||||
|
|
||||||
if self.remove_all_hidden:
|
if self.remove_all_hidden:
|
||||||
if self.multi_object:
|
if self.multi_object:
|
||||||
|
@ -342,11 +331,11 @@ class GPEXP_OT_remove_viewlayer_on_selected(bpy.types.Operator):
|
||||||
print(mess)
|
print(mess)
|
||||||
exclude_message.append(mess)
|
exclude_message.append(mess)
|
||||||
|
|
||||||
view_layers = [rd_scn.view_layers.get(l.viewlayer_render) for l in layers\
|
view_layers = [scn.view_layers.get(l.viewlayer_render) for l in layers\
|
||||||
if l.viewlayer_render and rd_scn.view_layers.get(l.viewlayer_render)]
|
if l.viewlayer_render and scn.view_layers.get(l.viewlayer_render)]
|
||||||
|
|
||||||
## remove nodes associated with those viewlayers
|
## remove nodes associated with those viewlayers
|
||||||
fn.remove_nodes_by_viewlayer(view_layers, scene=rd_scn)
|
fn.remove_nodes_by_viewlayer(view_layers, scene=scn)
|
||||||
|
|
||||||
## Set selected those layer viewlayer exclude
|
## Set selected those layer viewlayer exclude
|
||||||
for l in layers:
|
for l in layers:
|
||||||
|
|
|
@ -245,12 +245,6 @@ class GPEXP_OT_export_as_pdf(bpy.types.Operator):
|
||||||
return 'Export layers as individual SWF files, using scene range'
|
return 'Export layers as individual SWF files, using scene range'
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# rd_scn = bpy.data.scenes.get('Render')
|
|
||||||
# if not rd_scn:
|
|
||||||
# self.report({'ERROR'}, 'Viewlayers needs to be generated first!')
|
|
||||||
# return {'CANCELLED'}
|
|
||||||
|
|
||||||
|
|
||||||
### store
|
### store
|
||||||
## dict all visible objects as key with value : sub dict {layer : hide_bool}
|
## dict all visible objects as key with value : sub dict {layer : hide_bool}
|
||||||
|
|
||||||
|
|
|
@ -330,11 +330,6 @@ class GPEXP_OT_layers_state(bpy.types.Operator):
|
||||||
|
|
||||||
fn.show_message_box(_message=changes, _title="Layers Check Report", _icon='INFO')
|
fn.show_message_box(_message=changes, _title="Layers Check Report", _icon='INFO')
|
||||||
|
|
||||||
# render = bpy.data.scenes.get('Render')
|
|
||||||
# if not render:
|
|
||||||
# print('SKIP, no Render scene')
|
|
||||||
# return {"CANCELLED"}
|
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
class GPEXP_OT_lower_layers_name(bpy.types.Operator):
|
class GPEXP_OT_lower_layers_name(bpy.types.Operator):
|
||||||
|
|
9
fn.py
9
fn.py
|
@ -262,12 +262,6 @@ def get_render_scene():
|
||||||
## With data
|
## With data
|
||||||
render_scn = bpy.data.scenes.new('Render')
|
render_scn = bpy.data.scenes.new('Render')
|
||||||
|
|
||||||
## With ops (goes directly into scene)
|
|
||||||
# bpy.ops.scene.new(type='NEW')
|
|
||||||
# render_scn = bpy.context.scene
|
|
||||||
# print('render_scn: ', render_scn)
|
|
||||||
# render_scn.name = 'Render'
|
|
||||||
|
|
||||||
## copy original settings over to new scene
|
## copy original settings over to new scene
|
||||||
# copy_settings(current, render_scn) # BAD
|
# copy_settings(current, render_scn) # BAD
|
||||||
for attr in ['frame_start', 'frame_end', 'frame_current', 'camera', 'world']:
|
for attr in ['frame_start', 'frame_end', 'frame_current', 'camera', 'world']:
|
||||||
|
@ -1263,9 +1257,6 @@ def export_crop_to_json() -> dict:
|
||||||
coord_dic = {}
|
coord_dic = {}
|
||||||
|
|
||||||
for scn in bpy.data.scenes:
|
for scn in bpy.data.scenes:
|
||||||
# if scn.name in {'Scene', 'Render'}:
|
|
||||||
# if scn.name == 'Scene':
|
|
||||||
# continue
|
|
||||||
if scn.render.use_border and scn.render.use_crop_to_border: # Only usefull if cropped
|
if scn.render.use_border and scn.render.use_crop_to_border: # Only usefull if cropped
|
||||||
scn_border = get_crop_pixel_coord(scn)
|
scn_border = get_crop_pixel_coord(scn)
|
||||||
## Only scn name (meaning only one name to refer if multiple GP)
|
## Only scn name (meaning only one name to refer if multiple GP)
|
||||||
|
|
Loading…
Reference in New Issue