refactor and fixes for episode handling gav
This commit is contained in:
+43
-12
@@ -103,11 +103,27 @@ def get_channel_name(strip):
|
||||
return scn.sequence_editor.channels[strip.channel].name
|
||||
|
||||
def get_strip_sequence_name(strip):
|
||||
sequence_strip = get_strip_at(channel='Sequences', frame=strip.frame_final_start)
|
||||
"""Return the sequence strip directly above a shot strip."""
|
||||
scn = bpy.context.scene
|
||||
sequencer = scn.sequence_editor
|
||||
if not sequencer or not strip:
|
||||
return 'NoSequence'
|
||||
|
||||
# In the GAV layout, sequence strips are placed immediately above shot
|
||||
# strips (for example, Sequences on channel 3 and Shots on channel 2).
|
||||
sequence_strip = next(
|
||||
(
|
||||
candidate for candidate in sequencer.strips
|
||||
if candidate.channel == strip.channel + 1
|
||||
and candidate.frame_final_start <= strip.frame_final_start
|
||||
and candidate.frame_final_end >= strip.frame_final_end
|
||||
),
|
||||
None,
|
||||
)
|
||||
if sequence_strip:
|
||||
return sequence_strip.name
|
||||
else:
|
||||
return 'NoSequence'
|
||||
|
||||
return 'NoSequence'
|
||||
|
||||
def rename_strips(strips, template, increment=10, start_number=0, padding=3, by_sequence=False):
|
||||
scn = bpy.context.scene
|
||||
@@ -121,12 +137,24 @@ def rename_strips(strips, template, increment=10, start_number=0, padding=3, by_
|
||||
prev_sequence_name = None
|
||||
strip_number = 0
|
||||
|
||||
for strip in strips:
|
||||
planned_names = []
|
||||
for strip in strips:
|
||||
channel = get_channel_name(strip)
|
||||
sequence_name = get_strip_sequence_name(strip)
|
||||
format_data = {}
|
||||
if channel == 'Shots':
|
||||
format_data = parse(project.sequence_template, sequence_name)
|
||||
format_data = (
|
||||
parse(project.sequence_template, sequence_name)
|
||||
or parse(project.sequence_template, sequence_name.lower())
|
||||
or {}
|
||||
)
|
||||
if 'sequence' not in format_data:
|
||||
# Shots created directly from an animatic do not have a
|
||||
# parent Sequences strip yet. Use the configured first
|
||||
# sequence number until one is created.
|
||||
format_data['sequence'] = str(
|
||||
project.sequence_start_number
|
||||
).zfill(project.sequence_padding)
|
||||
else:
|
||||
format_data['sequence'] = str(strip_number*increment + start_number).zfill(padding)
|
||||
|
||||
@@ -141,15 +169,18 @@ def rename_strips(strips, template, increment=10, start_number=0, padding=3, by_
|
||||
|
||||
name = template.format(**format_data)
|
||||
|
||||
existing_strip = scn.sequence_editor.strips_all.get(name)
|
||||
if existing_strip:
|
||||
existing_strip.name = f"{name}_tmp"
|
||||
|
||||
planned_names.append((strip, name))
|
||||
prev_sequence_name = sequence_name
|
||||
strip_number += 1
|
||||
|
||||
# Clear all names first so renaming never collides with a later strip and
|
||||
# leaves a permanent `_tmp` suffix behind.
|
||||
for index, (strip, _) in enumerate(planned_names):
|
||||
strip.name = f"__vse_rename_{index:04d}"
|
||||
|
||||
for strip, name in planned_names:
|
||||
print(f'Renaming {strip.name} -> {name}')
|
||||
strip.name = name
|
||||
|
||||
prev_sequence_name = sequence_name
|
||||
strip_number += 1
|
||||
|
||||
def set_channels():
|
||||
scn = bpy.context.scene
|
||||
|
||||
Reference in New Issue
Block a user