i'm trying to write a little addon to show all strips used in a vse timeline. and i also want it to have a "reveal file in explorer" button. So far so good, i have this to show strips with a pop up menu :

        scene = bpy.context.scene
        strip = scene.sequence_editor.sequences_all
        activeST = scene.sequence_editor.active_strip
        rstrip = activeST

        for s in strip:
            if s.type == 'IMAGE':
                layout.label(s.name, icon='FILE_IMAGE')
                layout.label("  Start : " + str(s.frame_start) + "   End : " + str(int(s.frame_start)+int(s.frame_final_duration)-1))
            if s.type == 'SOUND':
                layout.label(s.name, icon='FILE_SOUND')
                layout.label("  Start : " + str(s.frame_start) + "   End : " + str(int(s.frame_start)+int(s.frame_final_duration)-1))
            if s.type == 'MOVIE':
                layout.label(s.name, icon='FILE_MOVIE')
                layout.label("  Start : " + str(s.frame_start) + "   End : " + str(int(s.frame_start)+int(s.frame_final_duration)-1))

all is working except for the custom "reveal.file_explorer" operator, here's its code :

def revealfileexplorer (s):

    if rstrip.type=='IMAGE':
        name='\\' + rstrip.elements[0].filename
        Npath=os.path.abspath(bpy.path.abspath(path)) + name
        subprocess.Popen('explorer /select,"'+Npath+'"')

    if rstrip.type=='MOVIE':
        subprocess.Popen('explorer /select,"'+Npath+'"')

    if rstrip.type=='SOUND':
        subprocess.Popen('explorer /select,"'+Npath+'"')

class RevealFile(bpy.types.Operator):
    """Reveal file in Explorer"""
    bl_idname = "reveal.file_explorer"
    bl_label = "Reveal"
    bl_options = {'REGISTER'}

    def execute(self, context):
        return {'FINISHED'}

I tried to pass the "s" value to make the operator different with every file, and opening the right one... but "name "s" is not defined" according to blender. I'm not a coder basically, and no clue on how to do this... Any help would be greatly appreciated :D thanks in advance !


1 Answer 1


The problem is that in the execute function, s is not defined, you need to tell the operator what is s.

A solution you could use is to add a property to the operator:

class AnimOperator(bpy.types.Operator):
    bl_idname = "object.anim_operator"
    bl_label = "Pose Anim Operator"
    s = bpy.props.StringProperty()
    def execute(self, context):
        return {'FINISHED'}

notice the self.s to access the s in the AnimOperator class instance

Then when calling the operator, you have to define the value of s.

op.s = s

I didn't try this code so I maybe made some mistakes but you have the idea.

Those are object oriented programming and concepts and the scope of a variable problems, you'll maybe need to learn a little about that if you want to use programming language for more complex program.

Edit: I'm a little tired right now but looking back to you code there is another problem, you don't use s but rstrip in the revealfileexplorer function. I also suggest you to use the StringProperty but this will only accept text. I never tried to use complex types as operator parameter I think you are limited to Blender properties types but I'm not sure about that, I will test that tomorrow to give you a more precise answer if you need, but for now I think that you can solve your problem using only string, maybe with multiple StringProperty if needed. You can also use a IntProperty, and pass the index as parameter, and then find your strip like that:

def revealfileexplorer (id):
     s = bpy.context.scene.sequence_editor.sequences_all[id] 
  • $\begingroup$ bpy.ops.transform.translate(value=(0, 0, 10)) Passing the parameters down this way works too. $\endgroup$
    – TeaCrab
    Commented Jun 25, 2017 at 1:13
  • $\begingroup$ hey thank you very much for the answer ! you're right about rstrip, it was part of another little "test script' i forgot to change ! I had it work using your example, using a string value to store the entire filepath before calling the operator. so the operator is just composed by the subprocess ! Thanks for the quick reply and the explanation ! :) $\endgroup$
    – tonton
    Commented Jun 25, 2017 at 10:40

You must log in to answer this question.

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