Added "loop" pattern name parsing for sequences

When this gets released, we need to add documentation for all the naming tricks because it's getting a bit out of hand now and I need documentation even just for myself.
This commit is contained in:
Colin Basnett
2026-01-02 16:32:14 -08:00
parent 5edebd3477
commit f3b5ac9daf

View File

@@ -61,6 +61,27 @@ class PSA_PG_export_nla_strip_list_item(PropertyGroup):
def get_sequences_from_name_and_frame_range(name: str, frame_start: int, frame_end: int):
# Check for loop
anims: List[tuple[str, int, int]] = []
loop_pattern = r'\@(\d+)\:(.+)'
loop_match = re.match(loop_pattern, name)
if loop_match:
frame_count = max(1, int(loop_match.group(1)))
sequence_name = loop_match.group(2)
iteration = 0
frame = frame_start
while frame + frame_count <= frame_end:
output_name = sequence_name.format(index=iteration)
iteration_frame_start = frame
iteration_frame_end = frame + frame_count - 1
anims.append((output_name, iteration_frame_start, iteration_frame_end))
frame += frame_count
iteration += 1
else:
# If not, just treat it as a single animation, but parse for the reverse pattern as well.
anims.append((name, frame_start, frame_end))
for (name, frame_start, frame_end) in anims:
reversed_pattern = r'(.+)/(.+)'
reversed_match = re.match(reversed_pattern, name)
if reversed_match: