1
$\begingroup$

i'm trying to access and change the filename of image strips in the sequencer for a little addon i'm developping, but i'm stuck with invalid syntax, i think, and i can't find the correct way to put that... Here's what i've got so far :

import bpy


for scene in bpy.data.scenes: 

    if scene.sequence_editor is not None:

        strip = scene.sequence_editor.sequences_all

        if strip is not None:
            for obj in strip:
                if obj.type == 'IMAGE':

                    obj.elements.Sequence_Element.filename="ok"

But last line doesn't work... Does anyone have an idea about that ? Or know the correct way ? Thank you very much !

$\endgroup$

1 Answer 1

3
$\begingroup$

The Sequencer Strip has a name property, which is assigned by the user in Blender. It also has an SequenceElement list which contains all "file" elements of that strip. (Especially with image sequences you have multiple files.) We need to access the SequenceElements filename property. Image strips only have a single SequenceElement which will be indiced with 0.

The correct code is:

import bpy

for scene in bpy.data.scenes: 
    if scene.sequence_editor is not None:
        strip = scene.sequence_editor.sequences_all
        if strip is not None:
            for obj in strip:
                if obj.type == 'IMAGE':
                    obj.name = "ok"
                    obj.elements[0].filename = "ok.png"
$\endgroup$
1
  • $\begingroup$ perfect thanks you @Leander ! works like a charm ! i was aware of the name attribute, but i want to let it unchanged (because it's up to user to rename its strips) but i didn't know the good way to get to the elements attribute ! perfect ! $\endgroup$
    – tonton
    Commented Feb 5, 2017 at 23:50

You must log in to answer this question.

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