There doesn't seem to be any way to get or set the source length of an automation item through the API (except of course by saving the project first and looking for SRCLEN...). This would be useful for many scripts (I stumbled upon this while trying to do a
Replace looped automation item with individual items).
Code:
local env = reaper.GetSelectedTrackEnvelope(0)
local srclen = reaper.GetSetAutomationItemInfo(env, 1, 'D_LENGTHSRC', 0, false)