3
$\begingroup$

I use the following code to add a text strip:

tStripAdd = "frame_start=" + fStart + ", frame_end=" + fEnd + ", channel=" + tChan + ", type='TEXT'"
print('tStripAdd = ' + tStripAdd)
#tStripAdd = frame_start=1, frame_end=164, channel=4, type='TEXT'- result of print command
bpy.ops.sequencer.effect_strip_add(tStripAdd)

I get the following error:

TypeError: Calling operator "bpy.ops.sequencer.effect_strip_add" error, expected a string enum in ('INVOKE_DEFAULT', 'INVOKE_REGION_WIN', 'INVOKE_REGION_CHANNELS', 'INVOKE_REGION_PREVIEW', 'INVOKE_AREA', 'INVOKE_SCREEN', 'EXEC_DEFAULT', 'EXEC_REGION_WIN', 'EXEC_REGION_CHANNELS', 'EXEC_REGION_PREVIEW', 'EXEC_AREA', 'EXEC_SCREEN')

Any suggestion as to what the problem is? How to solve it?

$\endgroup$

2 Answers 2

5
$\begingroup$

You are passing a string into the function instead of the actual arguments. Since effect_strip_add doesn't have any function signature that takes a string as first arguments you're getting the TypeError exception. The concept of keyword arguments is explained in this section of the Python docs.

The proper way of calling the function is passing each of the arguments.

bpy.ops.sequencer.effect_strip_add(frame_start=fStart, frame_end=fEnd, channel=tChan, type='TEXT')

bpy.ops.sequencer.effect_strip_add is documented in Blender 2.8 Python API with the following function signature:

bpy.ops.sequencer.effect_strip_add(frame_start=0, frame_end=0, channel=1, replace_sel=True, overlap=False, type='ALPHA_OVER', color=(0.0, 0.0, 0.0))

Add an effect to the sequencer, most are applied on top of existing strips

Parameters:

  • frame_start (int in [-inf, inf], (optional)) – Start Frame, Start frame of the sequence strip
  • frame_end (int in [-inf, inf], (optional)) – End Frame, End frame for the color strip
  • channel (int in [1, 32], (optional)) – Channel, Channel to place this strip into
  • replace_sel (boolean, (optional)) – Replace Selection, Replace the current selection
  • overlap (boolean, (optional)) – Allow Overlap, Don’t correct overlap on new sequence strips
  • type (enum in ['CROSS', 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED', 'MULTICAM', 'ADJUSTMENT', 'GAUSSIAN_BLUR', 'TEXT', 'COLORMIX'], (optional)) – Type, Sequencer effect type

    • CROSS Crossfade, Crossfade effect strip type.
    • ADD Add, Add effect strip type.
    • SUBTRACT Subtract, Subtract effect strip type.
    • ALPHA_OVER Alpha Over, Alpha Over effect strip type.
    • ALPHA_UNDER Alpha Under, Alpha Under effect strip type.
    • GAMMA_CROSS Gamma Cross, Gamma Cross effect strip type.
    • MULTIPLY Multiply, Multiply effect strip type.
    • OVER_DROP Alpha Over Drop, Alpha Over Drop effect strip type.
    • WIPE Wipe, Wipe effect strip type.
    • GLOW Glow, Glow effect strip type.
    • TRANSFORM Transform, Transform effect strip type.
    • COLOR Color, Color effect strip type.
    • SPEED Speed, Color effect strip type.
    • MULTICAM Multicam Selector.
    • ADJUSTMENT Adjustment Layer.
    • GAUSSIAN_BLUR Gaussian Blur.
    • TEXT Text.
    • COLORMIX Color Mix.
  • color (float array of 3 items in [0, 1], (optional)) – Color, Initialize the strip with this color (only used when type=’COLOR’)

$\endgroup$
4
  • $\begingroup$ Thank you. Tat's one more problem solved. On to the next. $\endgroup$
    – mcgeo52
    Commented Sep 7, 2019 at 9:14
  • $\begingroup$ On second thought, no. It does not work. I do get a different error message: Traceback (most recent call last): File "/home/ec2-user/proj005/proj005.py", line 137, in <module> bpy.ops.sequencer.effect_strip_add(frame_start=fStart, frame_end=fEnd, channel=tChan, type='TEXT') File "/home/ec2-user/blender280/2.80/scripts/modules/bpy/ops.py", line 201, in call ret = op_call(self.idname_py(), None, kw) RuntimeError: Operator bpy.ops.sequencer.effect_strip_add.poll() failed, context is incorrect $\endgroup$
    – mcgeo52
    Commented Sep 7, 2019 at 9:20
  • $\begingroup$ @mcgeo52 It is correct. You are not in the right context to execute the operator though. $\endgroup$ Commented Sep 7, 2019 at 9:21
  • $\begingroup$ This does work: eff = sequences.new_effect( name=tField, type="TEXT", channel=tChan, frame_start=fStart, frame_end=fEnd) $\endgroup$
    – mcgeo52
    Commented Sep 7, 2019 at 9:51
0
$\begingroup$

This works:

    eff = sequences.new_effect(
        name=tField,
        type="TEXT",
        channel=tChan,
        frame_start=fStart,
        frame_end=fEnd)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .