Best way to change UV set in code

What's the best way to change the UV set in code. I find that, for example Genesis2 has 30 or more materials and each one has a UV set parameter. Is there an easier way to change the UV set other than doing it on each material? The end result is I want to export an obj file of each UV.
Thanks