diff --git a/sequencer_utils.py b/sequencer_utils.py index be95ebb..446e4f7 100644 --- a/sequencer_utils.py +++ b/sequencer_utils.py @@ -237,7 +237,7 @@ def render_strips(strips, template): scn.frame_end = scene_end scn.render.filepath = render_path -def import_edit(filepath, adapter="cmx_3600", clean_sequencer=False): +def import_edit(filepath, adapter="cmx_3600", clear=False): import opentimelineio as otio from opentimelineio.schema import ( Clip, @@ -250,15 +250,11 @@ def import_edit(filepath, adapter="cmx_3600", clean_sequencer=False): ) scn = bpy.context.scene - sequences = scn.sequence_editor.sequences + sequencer = scn.sequence_editor.sequences - if clean_sequencer: - movie = get_strips(channel='Movie') - audio = get_strips(channel='Audio') - - for strip in sequences: - if strip not in (movie+audio): - sequences.remove(strip) + if clear: + for strip in get_strips(channel='Shots'): + sequencer.remove(strip) edl = Path(filepath) try: @@ -293,13 +289,22 @@ def import_edit(filepath, adapter="cmx_3600", clean_sequencer=False): child.range_in_parent().duration) try: - strip = sequences.new_effect( - name=child.name, - type='COLOR', - channel=channel, - frame_start=frame_start, - frame_end=frame_end, - ) + strip = next((s for s in sequencer.sequences if s.vsetb_strip_settings.source_name == child.name)) + if strip: + if frame_start != strip.frame_final_start or frame_end !=strip.frame_final_end: + self.report({'INFO'}, f'The strip {strip.name} is updated with new range') + + strip.frame_final_start = frame_start + strip.frame_final_end = frame_end + else: + strip = sequences.new_effect( + name=child.name, + type='COLOR', + channel=channel, + frame_start=frame_start, + frame_end=frame_end, + ) + strip.blend_alpha = 0.0 strip.select = False strip.vsetb_strip_settings.source_name = child.name