From b68b43e3e1c0c289ea2de3e2991cc99b438ae1dc Mon Sep 17 00:00:00 2001 From: "florentin.luce" Date: Thu, 23 May 2024 10:07:43 +0200 Subject: [PATCH] new operator to merge shots --- operators/sequencer.py | 33 +++++++++++++++++++++++++-------- ui/panels.py | 3 ++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/operators/sequencer.py b/operators/sequencer.py index fb591da..7052703 100644 --- a/operators/sequencer.py +++ b/operators/sequencer.py @@ -563,19 +563,32 @@ class WM_OT_split_view(Operator): return {"FINISHED"} -''' -class VSETB_OT_set_review_workspace(Operator): - """Set Review Workspace""" - bl_idname = "vse_toolbox.set_workspace" - bl_label = "Set Review Workspace" +class VSETB_OT_merge_shot_strips(Operator): + """Merge selected shots strips (required at least two strips).""" + bl_idname = "vse_toolbox.merge_shot_strips" + bl_label = "Merge Shot Strips" + + @classmethod + def poll(cls, context): + + selected_strips = bpy.context.selected_sequences + if len(selected_strips) <= 1: + return False + + return all(get_channel_name(strip) == 'Shots' for strip in selected_strips) def execute(self, context): - bpy.ops.workspace.append_activate(idname='Review', filepath=str(REVIEW_TEMPLATE_BLEND)) + selected_strips = bpy.context.selected_sequences + last_frame = selected_strips[-1].frame_final_end + + for i in range(1, len(selected_strips)): + context.scene.sequence_editor.sequences.remove(selected_strips[i]) + + selected_strips[0].frame_final_end = last_frame return {"FINISHED"} - ''' addon_keymaps = [] @@ -595,6 +608,9 @@ def register_keymaps(): kmi = km.keymap_items.new('vse_toolbox.next_shot', type='RIGHT_ARROW', value='PRESS', ctrl=True) addon_keymaps.append((km, kmi)) + kmi = km.keymap_items.new('vse_toolbox.merge_shot_strips', type='J', value='PRESS', ctrl=True) + addon_keymaps.append((km, kmi)) + def unregister_keymaps(): #print('unregister_keymaps', addon_keymaps) @@ -617,7 +633,8 @@ classes = ( VSETB_OT_collect_files, VSETB_OT_insert_channel, VSETB_OT_remove_channel, - WM_OT_split_view + VSETB_OT_merge_shot_strips, + WM_OT_split_view, ) def register(): diff --git a/ui/panels.py b/ui/panels.py index 03bd307..cf3c13d 100644 --- a/ui/panels.py +++ b/ui/panels.py @@ -451,7 +451,8 @@ class VSETB_MT_main_menu(Menu): layout.separator() layout.operator('vse_toolbox.insert_channel', text='Insert Channel', icon='TRIA_UP_BAR') layout.operator('vse_toolbox.remove_channel', text='Remove Channel', icon='TRIA_DOWN_BAR') - + layout.separator() + layout.operator('vse_toolbox.merge_shot_strips', text='Merge Shots') def draw_vse_toolbox_menu(self, context): self.layout.menu("VSETB_MT_main_menu")