I'm working on a script to flip through the basic track envelopes for all selected tracks, and ran into a bit of a snag.
The native actions for
Track: Select volume envelope only apply to the first selected track, which isn't normally a problem. I grab all of the tracks, loop through, select them one at a time using
SetOnlyTrackSelected, and run the action on each of them individually. Easy peasy, I've done it a million times for similar situations.
Nope. It still only works on the first track. Example script:
Code:
local function Msg(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n")
end
-- Count selected tracks
local tracks = {}
local count = reaper.CountSelectedTracks(0)
if count == 0 then return end
-- Get all of their MediaTracks
for i = 0, count - 1 do
tracks[i] = reaper.GetSelectedTrack(0, i)
end
-- Select the envelopes individually
for _, track in pairs(tracks) do
Msg("selecting only track " .. _)
reaper.SetOnlyTrackSelected(track)
Msg("there are currently " .. reaper.CountSelectedTracks(0) .. " selected tracks")
reaper.Main_OnCommand(41866, 0) -- Track: Select volume envelope
end
-- Restore the track selection
for _, track in pairs(tracks) do
reaper.SetTrackSelected(track, true)
end
Bug, or PEBKAC? Cheers.
(I can't use envelope chunks because the envelope may or may not exist yet)