2
$\begingroup$

In 2.80 I can add a Text effect strip with the following:

 effName = "eff" + tCStr[-3:] effName = sequences.new_effect( name=tField, type="TEXT", channel=tChan, frame_start=fStart, frame_end=fEnd) 

That works fine.

However, I also need to remove the strip.

I can remove Image strips with:

sequences.remove(image_strip1) 

And I can remove Sound strips with:

sequences.remove(sound_strip1) 

I have tried all of the following to remove the Text strips with results as shown.

I'm sure there is a simple way to do this, or failing that, at least some way to do it.

Notes:

• effName is set to a range of values from eff000 to eff010

• tField is set to a range of values from Text0000 to Text0010

• xName is set to either effxxx or Textxxxx

sequences.remove_effect(xName) 

AttributeError: 'bpy_prop_collection' object has no attribute 'remove_effect'

sequences.effect_strip_remove(xName) 

AttributeError: 'bpy_prop_collection' object has no attribute 'effect_strip_remove'

sequences.remove(xName) 

TypeError: Sequences.remove(): error with argument 1, "sequence" - Function.sequence expected a Sequence type, not str

sequences.remove(eval(xName)) 

File "<'string>", line 1, in NameError: name 'eff000' is not defined

sequences.remove(eval(xName)) 

File "<'string>", line 1, in NameError: name 'Text0000' is not defined

$\endgroup$

1 Answer 1

4
$\begingroup$

You have to pass an object of type bpy.types.Sequence into bpy.types.Sequences.remove(). This means you can pass the return value of sequences.new_effect() into sequences.remove(). In the example in your question that reference would be stored in effName.

bpy.context.scene.sequence_editor.sequences.remove(effName) 

If you don't have a reference to the sequence anymore, you will have to retrieve it from:

bpy.context.scene.sequence_editor.sequences_all 

Update: Since there seems to be some misunderstanding about my explanation, you find a fully functional code example below. As I said before, you need to store the return value of new_effect() to later us it as input for remove().

import bpy sequences = bpy.context.scene.sequence_editor.sequences names = ['a', 'b', 'c'] tChan = 0 fStart = 0 fEnd = 50 text_effects = [] for name in names: text_effect_strip = sequences.new_effect( name=name, type='TEXT', channel=tChan, frame_start=fStart, frame_end=fEnd ) text_effects.append(text_effect_strip) for text_effect_strip in text_effects: sequences.remove(text_effect_strip) 
$\endgroup$
11
  • $\begingroup$ When I tried what you suggested i got: TypeError: Sequences.remove(): error with argument 1, "sequence" - Function.sequence expected a Sequence type, not str -- So I tried bpy.context.scene.sequence_editor.sequences.remove(eval(effName)) and got: File "<'string>", line 1, in NameError: name 'eff000' is not defined -- I assume this means I need to use: bpy.context.scene.sequence_editor.sequences_all -- How do I do that? $\endgroup$ Commented Sep 11, 2019 at 7:22
  • $\begingroup$ I assumed that effName contains the return value of sequences.new_effect as shown in your example above. Store the return value of sequences.new_effect and pass that value to sequences.remove. $\endgroup$ Commented Sep 11, 2019 at 7:24
  • $\begingroup$ I have tried every possible iteration I can think of for sequences.remove; see the notes in my question. None of them work. What am I missing? $\endgroup$ Commented Sep 11, 2019 at 7:39
  • $\begingroup$ @batFINGER, any insight? $\endgroup$ Commented Sep 11, 2019 at 7:52
  • 1
    $\begingroup$ @mcgeo52 That doesn't really change the approach though. I have added an example to my answer that should make things more clear. $\endgroup$ Commented Sep 11, 2019 at 8:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.