Function for getting the index of the Selected Visible Track
As far as I know there’s no function integrated in the code to easily get the position of a Selected Visible Track inside of the Visible Tracks list. You might need this position when you’ve got closed Group Tracks in your Tracks list.
The Visible Tracks list is also a vector custom built by Ableton that doesn’t have its own `.index()` method.
To get the position you need to compare the selected Track Object with all Track Objects inside the Visible Tracks list until you find a match. Here’s a function that does this:
def get_selected_visible_track_num(): track_num = self.get_selected_track_num() track = self.song().tracks[track_num] for i in range(len(self.song().visible_tracks)): visible_track = self.song().visible_tracks[i] if visible_track == track: return i
Glenn V. Asked question
Sign up
User registration is currently not allowed.