fix refacto
This commit is contained in:
+40
-38
@@ -101,7 +101,7 @@ def rename_strips(
|
||||
sequence_name = get_strip_sequence_name(strip)
|
||||
|
||||
if (by_sequence and prev_sequence_name and
|
||||
sequence_name and sequence != prev_sequence_name):
|
||||
sequence_name and sequence_name != prev_sequence_name):
|
||||
strip_number = 0
|
||||
|
||||
name = template.format(
|
||||
@@ -239,9 +239,9 @@ def render_strips(strips, template):
|
||||
scn.render.filepath = render_path
|
||||
|
||||
def import_edit(filepath, adapter="cmx_3600", channel='Shots'):
|
||||
otio = install_module('opentimelineio')
|
||||
opentimelineio = install_module('opentimelineio')
|
||||
|
||||
from otio.schema import (
|
||||
from opentimelineio.schema import (
|
||||
Clip,
|
||||
ExternalReference,
|
||||
Gap,
|
||||
@@ -254,13 +254,9 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots'):
|
||||
scn = bpy.context.scene
|
||||
sequencer = scn.sequence_editor.sequences
|
||||
|
||||
if clear:
|
||||
for strip in get_strips(channel='Shots'):
|
||||
sequencer.remove(strip)
|
||||
|
||||
edl = Path(filepath)
|
||||
try:
|
||||
timeline = otio.adapters.read_from_file(
|
||||
timeline = opentimelineio.adapters.read_from_file(
|
||||
str(edl), adapter, rate=scn.render.fps, ignore_timecode_mismatch=True)
|
||||
except:
|
||||
print("[>.] read_from_file Failed. Using read_from_string method.")
|
||||
@@ -284,36 +280,37 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots'):
|
||||
continue
|
||||
|
||||
channel = get_channel_index('Shots')
|
||||
frame_start = otio.opentime.to_frames(
|
||||
frame_start = opentimelineio.opentime.to_frames(
|
||||
child.range_in_parent().start_time)
|
||||
|
||||
frame_end = frame_start + otio.opentime.to_frames(
|
||||
frame_end = frame_start + opentimelineio.opentime.to_frames(
|
||||
child.range_in_parent().duration)
|
||||
|
||||
try:
|
||||
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')
|
||||
#try:
|
||||
strip = next((s for s in sequencer if s.vsetb_strip_settings.source_name == child.name), None)
|
||||
if strip:
|
||||
if frame_start != strip.frame_final_start or frame_end !=strip.frame_final_end:
|
||||
print(f'The strip {strip.name} is updated with new range')
|
||||
#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 = sequencer.new_effect(
|
||||
name=child.name,
|
||||
type='COLOR',
|
||||
channel=channel,
|
||||
frame_start=frame_start,
|
||||
frame_end=frame_end,
|
||||
)
|
||||
strip.frame_final_start = frame_start
|
||||
strip.frame_final_end = frame_end
|
||||
else:
|
||||
strip = sequencer.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
|
||||
strip.blend_alpha = 0.0
|
||||
strip.select = False
|
||||
strip.vsetb_strip_settings.source_name = child.name
|
||||
|
||||
except Exception as e:
|
||||
print('e: ', e)
|
||||
continue
|
||||
#except Exception as e:
|
||||
# print('e: ', e)
|
||||
# continue
|
||||
|
||||
scn.frame_end = frame_end-1
|
||||
return timeline
|
||||
@@ -377,23 +374,28 @@ def clean_sequencer(edit=False, movie=False, sound=False):
|
||||
|
||||
@persistent
|
||||
def set_active_strip(scene):
|
||||
#scn = bpy.context.scene
|
||||
settings = get_scene_settings()
|
||||
|
||||
if not settings.auto_select_strip:
|
||||
scn = bpy.context.scene
|
||||
if not scn.sequence_editor:
|
||||
return
|
||||
|
||||
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||
|
||||
if not get_scene_settings().auto_select_strip:
|
||||
return
|
||||
|
||||
|
||||
#scene.sequence_editor.active_strip = None
|
||||
|
||||
shot_strip = get_strip_at('Shots')
|
||||
if shot_strip:
|
||||
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||
shot_strip.select = True
|
||||
scene.sequence_editor.active_strip = shot_strip
|
||||
|
||||
@persistent
|
||||
def update_text_strips(scene):
|
||||
#scn = bpy.context.scene
|
||||
scn = bpy.context.scene
|
||||
if not scn.sequence_editor:
|
||||
return
|
||||
|
||||
format_data = {
|
||||
'scene': scene,
|
||||
'active_shot_name': 'None',
|
||||
|
||||
Reference in New Issue
Block a user