Clear Pattern Track Lines, But Not Automation

Is there an easy way to clear all the lines of a pattern track without touching the automation?

This one deletes both lines and automation

– Deletes all lines & automation.
renoise.song().patterns[].tracks[]:clear()

while this one clears only a single line.

– Clear all note and effect columns.
renoise.song().patterns[].tracks[].lines[]:clear()

I’m hoping I missed a simple call.

I would probably do like this:

  
function clear_pattern_data(pattern, track)  
 for line in ipairs(renoise.song():pattern(pattern):track(track).lines) do  
 renoise.song():pattern(pattern):track(track):line(line):clear()  
 end  
end  
  
clear_pattern_data(1, 1)  
  
  
local track = 1  
local pattern = 1  
if not renoise.song().patterns[pattern].tracks[track].is_empty then  
 for _ = 1, renoise.song().patterns[pattern].number_of_lines do  
 renoise.song().patterns[pattern].tracks[track].lines[_]:clear()  
 }  
}  
  

I guess that for loop is faster than what i suggested. Would checking line.is_empty optimize it further, or is that superfluous?

This should do, as fast as currently possible:

  
local pattern_index, track_index = 1, 1  
local pattern_iter = renoise.song().pattern_iterator  
for pos,line in pattern_iter:lines_in_pattern_track(pattern_index, track_index) do  
 line:clear()  
end  
  

Or:

  
local pattern_index, track_index = 1, 1  
  
local pattern = renoise.song():pattern(pattern_index)  
local pattern_track = pattern:track(track_index)  
  
if (not pattern_track.is_empty) then  
 for line_index = 1, pattern.number_of_lines do  
 pattern_track:line(line_index):clear()  
 end  
end  
  

Thanks for all the replies. Since I had a reference to a pattern track this is what I ended up using:

  
for i,v in ipairs(pattern_track.lines) do  
 v:clear()  
end