The trick is to enable and disable the tracks that you want to be involved, not want to be involved.
You might want to spy inside the Freeze Track tool, that does a similar thing. Though the tool is for 2.8, it might be just a few adjustments to make it work in Renoise 3.0
You’re aware that renoise can already render all tracks/patterns into single files? (Two checkboxes in the rendering dialog)
That said, the Freeze track tool is good starting point indeed.
something like:
local render_items = {}
function fill_items() end
-- recursively render all items in the table
function render()
for all_items do
if not item.rendered then
item.track:solo()
item.rendered = renoise.song():render(..., render())
end
end
end