Skip to main content
Tweeted twitter.com/StackBlender/status/1011818871232360448
Clarification, grammar, rewording to be more useful to others with a similar problem
Source Link

How to programmatically selectadd an effect strip on sequence editor or ...?

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?

How to programmatically select strip on sequence editor or ...?

I have some test images. I want import all images into sequence editor, one image per one channel. But i want add for each image transform effect strip and tune it. I want make it 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
    c += 2
    if c == 21:
        break

You can see - i skip one channel between images. I want insert here effect strip. I try it as:

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 to programmatically select sequence for add effect strip?

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?

Bumped by Community user
Bumped by Community user
Add scripting tag
Link
Deep
  • 191
  • 5
Source Link
Deep
  • 191
  • 5

How to programmatically select strip on sequence editor or ...?

I have some test images. I want import all images into sequence editor, one image per one channel. But i want add for each image transform effect strip and tune it. I want make it 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
    c += 2
    if c == 21:
        break

You can see - i skip one channel between images. I want insert here effect strip. I try it as:

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 to programmatically select sequence for add effect strip?