How do I detect with Python a strip in VSE being selected with the mouse?
I want to use the strips in the sequencer as buttons to select cameras in the 3D View. So I just want to detect the moment a strip is clicked.
How do I detect with Python a strip in VSE being selected with the mouse?
I want to use the strips in the sequencer as buttons to select cameras in the 3D View. So I just want to detect the moment a strip is clicked.
This script will print to console the name of the new strip being selected in the sequencer:
import bpy
oldStrip = bpy.context.scene.sequence_editor.active_strip
def sequencer_update(scene):
global oldStrip
activeStrip = scene.sequence_editor.active_strip
if activeStrip:
if oldStrip.name != activeStrip.name:
print("New strip selected: "+activeStrip.name)
oldStrip = activeStrip
def register():
handlers = bpy.app.handlers.scene_update_pre
for handler in handlers:
if ("sequencer_update" in str(handler)):
handlers.remove(handler)
handlers.append(sequencer_update)
def unregister():
handlers = bpy.app.handlers.scene_update_pre
for handler in handlers:
if ("sequencer_update" in str(handler)):
handlers.remove(handler)
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
#unregister()
Related: how-to-detect-updates-in-sequencer-by-comparing-to-a-global-variable
def handler(scene):and in the handler,strip = scene.sequence_editor.active_strip. – batFINGER Jan 04 '18 at 14:37