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
print(rstrip)
#images/videos/sons
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))
layout.operator('reveal.file_explorer')
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))
layout.operator('reveal.file_explorer')
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))
layout.operator('reveal.file_explorer')
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
path=rstrip.directory
Npath=os.path.abspath(bpy.path.abspath(path)) + name
print(Npath)
subprocess.Popen('explorer /select,"'+Npath+'"')
if rstrip.type=='MOVIE':
path=rstrip.filepath
Npath=os.path.abspath(bpy.path.abspath(path))
print(Npath)
subprocess.Popen('explorer /select,"'+Npath+'"')
if rstrip.type=='SOUND':
path=rstrip.sound.filepath
Npath=os.path.abspath(bpy.path.abspath(path))
print(Npath)
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):
revealfileexplorer(s)
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 !