# Check how many trackers are selected

I'm writing a script for scaling in the movie clip editor. I need a way to check if there are two trackers selected, or if there are not. Is there something in the API to check how many trackers are in the bundle?

• Yes, there is a 'select' attribute. Iterate through the trackers and check if this is 'true' or 'false'. – p2or Nov 14 '15 at 0:42

import bpy

context = bpy.context

# choose from data
tracks = bpy.data.movieclips["clip_name"].tracking.objects

# choose from context
tracks = context.scene.active_clip.tracking.objects

# selected camera tracks
selected_camera_tracks = [t for t in tracks['Camera'].tracks if t.select]

# selected object_tracks
selected_object_tracks = [t for t in tracks['Object'].tracks if t.select]

# toggle selected object tracks
for t in tracks['Object'].tracks:
t.select = not t.select