Created
January 1, 2020 22:16
-
-
Save gabrielmontagne/3b1362c0420849fbc679adaae909b37e to your computer and use it in GitHub Desktop.
Split VSE strips en Python, usando un text de input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
text = 'parts.adoc' | |
def split_from_text(text): | |
lines = [l.body.strip() for l in bpy.data.texts[text].lines if l.body.strip()] | |
split_sequence(lines) | |
def split_sequence(lines=['aaa', 'bbb', 'cccc']): | |
parts = len(lines) | |
seq = bpy.context.selected_sequences[0] | |
end = seq.frame_final_end | |
start = seq.frame_final_start | |
duration = seq.frame_final_duration | |
assert duration > parts, 'sequence too short to be split' | |
part_duration = duration / parts | |
print('\n' * 5) | |
print('start', start) | |
print('end', end) | |
print('duration', duration) | |
print('\n' * 3) | |
for (cut, line) in zip(range(start, end, int(part_duration)), lines): | |
print('cut', line, cut) | |
if cut > start: | |
print(bpy.ops.sequencer.cut(frame=cut, type='SOFT', side='RIGHT')) | |
seq = bpy.context.selected_sequences[0] | |
seq.text = line | |
split_from_text(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment