I have some test images. I want import all images into the sequence editor, one image per one channel. But iI want to add for each imagea transform effect strip for each image and tune it. I want make itto do this all programmatically.
This is my test python script:
import os
import re
import bpy
from bpy import context
scene = context.scene
path = "/path/do/images"
files = os.listdir(path)
files.sort(key=lambda var:[int(x) if x.isdigit() else x for x in re.findall(r'[^0-9]|[0-9]+', var)])
c = 1
scene.sequence_editor_create()
for f in files:
seq = scene.sequence_editor.sequences.new_image(
name=f,
filepath=os.path.join(path, f),
channel=c,
frame_start=1)
seq.use_reverse_frames = False
seq.blend_type = "OVER_DROP"
seq.frame_final_duration = 240
# [INSERT TRANSFORM STRIP HERE]
c += 2
if c == 21:
break
You can see - iI skip one channel between images. I want to insert herethe effect strip in between.
I try it as I tried effect_strip_add
:
bpy.ops.sequencer.effect_strip_add(
type="TRANSFORM",
channel=(c+1),
frame_start=1)
But blender says:
ret = op_call(self.idname_py(), None, kw) RuntimeError: Operator bpy.ops.sequencer.effect_strip_add.poll() failed, context is incorrect
Ok. I presume current sequence must be selected. Or no?
How todo I programmatically select sequence for add an effect strip?