Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 08-04-2018, 08:34 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,492
Default API: Some OnCommand calls don't play nicely in loops (FIXED)

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)
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 08-04-2018, 04:04 PM   #2
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 747
Default

I tested this and it seems to be command 41866 and some similar commands. Basically anything showing an envelope.

Action `Toggle track volume envelope visible` (40406) works fine.
__________________
http://www.admiralbumblebee.com
Audio/DAW stuff, Woodworking, Programming and more... new posts every weekend.
Robert Randolph is offline   Reply With Quote
Old 08-05-2018, 05:56 PM   #3
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,453
Default

Ah the bug here (I think) is that SetOnlyTrackSelected() doesn't update the "last touched track" state, which is what those actions use. Fixing.
Justin is online now   Reply With Quote
Old 08-05-2018, 06:01 PM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,492
Default

+1, would report bug again.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.