View Single Post
Old 05-14-2019, 03:56 AM   #472
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,301
Default

Quote:
Originally Posted by Breeder View Post
I'm trying to set tempo envelope display range via .lua script but I can't seem to make REAPER redraw the envelope with the new values.

Code:
local tempoenvmin = reaper.SNM_GetIntConfigVar("tempoenvmin", -222)
local tempoenvmax = reaper.SNM_GetIntConfigVar("tempoenvmax", -222)

local button, value = reaper.GetUserInputs("Set tempo map display range", 2, "Min:,Max:", tempoenvmin .. "," .. tempoenvmax)
if button == true then
	local min, max = value:match'(.*),(.*)'
	min, max = math.floor(tonumber(min)), math.floor(tonumber(max))
	if min > max then local tmp = min; min = max; max = tmp; end
	if min <= 0 then min = tempoenvmin end

	reaper.PreventUIRefresh(1)
	reaper.SNM_SetIntConfigVar("tempoenvmin", min)
	reaper.SNM_SetIntConfigVar("tempoenvmax", max)
	reaper.PreventUIRefresh(-1)

	reaper.UpdateArrange()
	reaper.UpdateTimeline()
	reaper.TrackList_AdjustWindows(false)
end
Update API doesn't seem to work and so doesn't the show/hide tempo envelope action run after the script.

Anyone got any idea on how to do this?
Haven't tested this, but you could try triggering an update by zooming in once and zooming out once.
It's forced but may help.
If not, then it's probably a case,where setting the config-vars doesn't update the UI.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote