scene switch and fixes

0.2.2

- feat: quick scene switch with a button in `node_editor > view`
- fix: re-arrange frames tiny offset
- fix: renumering ignored selection
- ui: gp dopesheet > send multiple layers button
main
Pullusb 2021-09-14 18:54:30 +02:00
parent 07e5046bef
commit ac7de45311
6 changed files with 85 additions and 9 deletions

View File

@ -9,6 +9,13 @@ OR always duplicate (safe but heavy scenes...)
if duplicate, need to "connect" with namespace ('_duprender') or something
-->
0.2.2
- feat: quick scene switch with a button in `node_editor > view`
- fix: re-arrange frames tiny offset
- fix: renumering ignored selection
- ui: gp dopesheet > send multiple layers button
0.2.1
- feat: renumbering with keep existing values

View File

@ -29,7 +29,7 @@ class GPEXP_OT_number_outputs(bpy.types.Operator):
for fo in nodes:
if fo.type != 'OUTPUT_FILE':
continue
if self.mode == 'SELECT' and not fo.select:
if self.mode == 'SELECTED' and not fo.select:
continue
print(f'numbering {fo.name}')
ct += 1

50
OP_scene_switch.py Normal file
View File

@ -0,0 +1,50 @@
import bpy
class GPEXP_OT_render_scene_switch(bpy.types.Operator):
bl_idname = "gp.render_scene_switch"
bl_label = "Render Scene Switch"
bl_description = "Switch between render"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
return True
# mode : bpy.props.StringProperty(default='NORMAL', options={'SKIP_SAVE'})
def execute(self, context):
scenes = bpy.data.scenes
if len(scenes) < 2:
self.report({'ERROR'},'No other scene to go to')
return {"CANCELLED"}
if context.scene.name == 'Render':
scn = scenes.get('Scene')
if not scn: # get the next available scene
self.report({'WARNING'},'No scene named "Scene"')
slist = [s.name for s in scenes]
scn = scenes[(slist.index(bpy.context.scene.name) + 1) % len(scenes)]
else:
scn = scenes.get('Render')
if not scn:
self.report({'ERROR'},'No "Render" scene yet')
return {"CANCELLED"}
self.report({'INFO'},f'Switched to scene "{scn.name}"')
bpy.context.window.scene = scn
return {"FINISHED"}
classes=(
GPEXP_OT_render_scene_switch,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)

View File

@ -2,7 +2,7 @@ bl_info = {
"name": "GP exporter",
"description": "Organise export of gp layers through compositor output",
"author": "Samuel Bernou",
"version": (0, 2, 1),
"version": (0, 2, 2),
"blender": (2, 93, 0),
"location": "View3D",
"warning": "",
@ -17,6 +17,7 @@ from . import OP_clean
from . import OP_connect_toggle
from . import OP_manage_outputs
from . import OP_number_outputs
from . import OP_scene_switch
from . import ui
import bpy
@ -32,6 +33,7 @@ def register():
OP_merge_layers.register()
OP_manage_outputs.register()
OP_number_outputs.register()
OP_scene_switch.register()
ui.register()
# bpy.types.Scene.pgroup_name = bpy.props.PointerProperty(type = PROJ_PGT_settings)
@ -40,6 +42,7 @@ def unregister():
return
ui.unregister()
OP_scene_switch.unregister()
OP_number_outputs.unregister()
OP_manage_outputs.unregister()
OP_merge_layers.unregister()

2
fn.py
View File

@ -201,7 +201,7 @@ def rearrange_frames(node_tree):
## f[0] : frame
## move frame by offset needed (delta between real_loc and "fake" loc , minus offset)
f[0].location.y = (f[1].y - f[0].location.y) - top - offset
f[0].location.y = (f[1].y - f[0].location.y) - top - offset + 40 # + 40 to avoid offset when recalculating from 0 top
# f[0].location.y = f[1].y - top - offset
offset += f[2] + 300 # gap

28
ui.py
View File

@ -11,12 +11,14 @@ class GPEXP_PT_gp_node_ui(Panel):
bl_label = "Gpencil Render Manager"
def draw(self, context):
layout = self.layout
layout.operator('gp.render_scene_switch', icon='SCENE_DATA', text='Switch Scene')
if not context.scene.use_nodes or not context.scene.node_tree:
return
# TODO : add advanced bool checkbox to hide some options from the user
layout = self.layout
col = layout.column(align=True)
ct = len([n for n in context.scene.node_tree.nodes if n.type == 'R_LAYERS' and n.select])
txt = f'Merge {ct} Layer Nodes'
@ -44,8 +46,14 @@ class GPEXP_PT_gp_node_ui(Panel):
col.operator('gp.clean_compo_tree', icon='BRUSHES_ALL', text='Clean Nodes') # NODE_CORNER
col.separator()
col.operator('gp.number_outputs', icon='LINENUMBERS_ON', text='Renumber Selected outputs').mode = 'SELECTED'
# col.operator('gp.number_outputs', icon='LINENUMBERS_ON', text='Renumber outputs').mode = 'ALL'
## (re)number exports
ct = len([n for n in context.scene.node_tree.nodes if n.type == 'OUTPUT_FILE' and n.select])
txt = f'Renumber {ct} Selected outputs'
subcol = col.column()
subcol.enabled = bool(ct)
subcol.operator('gp.number_outputs', icon='LINENUMBERS_ON', text=txt).mode = 'SELECTED'
# col.operator('gp.number_outputs', icon='LINENUMBERS_ON', text='Renumber all outputs').mode = 'ALL'
layout.separator()
@ -75,12 +83,20 @@ class GPEXP_PT_gp_dopesheet_ui(Panel):
layout = self.layout
layout.label(text=context.object.name)
## On layers
if context.object and context.object.type == 'GPENCIL':
txt = f'{len([l for l in context.object.data.layers if l.select])} Layer(s) To Render'
else:
txt = 'Layer To Render'
layout.operator('gp.add_layer_to_render', icon='RENDERLAYERS', text=txt)
# merge (only accessible if multiple layers selected)
row = layout.row()
ct = len([l for l in context.object.data.layers if l.select])
txt = f'Merge {ct} layers'
# merge layers from dopesheet
layout.operator('gp.merge_selected_dopesheet_layers', text=txt, )
layout.enabled= ct > 1
row.operator('gp.merge_selected_dopesheet_layers', text=txt, )
row.enabled= ct > 1
def manager_ui(self, context):
'''appended to DATA_PT_gpencil_layers'''