A strip (sequence) is selected in the VSE when its select property is True. The selected strips are available via the context.selected_sequences
list, and the active strip is context.scene.sequence_editor.active_strip
Test code using modal timer operator. Prepended a toggle button to turn autoselect on / off, to the Sequence Editor header.
import bpy
from bpy.props import BoolProperty
from bl_ui.space_sequencer import act_strip
class SeqModalTimerOperator(bpy.types.Operator):
"""Operator which runs its self from a timer"""
bl_idname = "wm.modal_timer_operator"
bl_label = "Modal Timer Operator"
_timer = None
def modal(self, context, event):
scene = context.scene
active_strip = act_strip(context)
if event.type in {'ESC'} or not scene.auto_select:
self.cancel(context)
return {'CANCELLED'}
if event.type == 'TIMER' and active_strip:
# deselect everything
for o in scene.objects:
o.select = False
# select empties, make active active.
for s in context.selected_sequences:
empty = scene.objects.get("Fader_%d" % s.channel)
if empty:
empty.select = True
if s == active_strip:
scene.objects.active = empty
return {'PASS_THROUGH'}
def execute(self, context):
wm = context.window_manager
self._timer = wm.event_timer_add(0.1, context.window)
wm.modal_handler_add(self)
return {'RUNNING_MODAL'}
def cancel(self, context):
wm = context.window_manager
wm.event_timer_remove(self._timer)
def toggle_auto_select(self, context):
scene = context.scene
layout = self.layout
#layout.label("Auto Select")
layout.prop(scene, "auto_select", toggle=True)
def auto_select(self, context):
if self.auto_select:
bpy.ops.wm.modal_timer_operator()
def register():
bpy.utils.register_class(SeqModalTimerOperator)
bpy.types.Scene.auto_select = BoolProperty(
default=False,
name="Auto Select",
description="Turn on to Auto select Empties",
update=auto_select)
bpy.types.SEQUENCER_HT_header.prepend(toggle_auto_select)
def unregister():
bpy.utils.unregister_class(SeqModalTimerOperator)
if __name__ == "__main__":
register()