# How to programmatically add an effect strip

I have some test images. I want import all images into the sequence editor, one image per channel. But I want to add a transform effect strip for each image and tune it. I want to 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


I skip one channel between images. I want to insert the effect strip in between. 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

How do I programmatically add an effect strip?

• Beware of the channel limit (32 IIRC?), unfortunately Blender has an upper limit on available channels for any media. If you add more than the limit, your media will stack at the same location on the top channel. My workaround is to metastrip this last channel of media and break it out into a new 32 channel stack (in the metastrip) – 3pointedit Apr 30 '18 at 1:35

eff = scene.sequence_editor.sequences.new_effect(