'Illustrator script (or action) to make 1 random layer visible per group

Similar to this question but with adobe Illustrator: Photoshop action to make 1 random layer visible within each group

I want to use an illustrator script (or action) to generate images that are composed of a random sampling of grouped layers.

  1. With in each of the 12 groups, I want to make 1 layer per group visible.
  2. Export the visible layers as an svg. Bonus points if I can change the file format.
  3. Repeat the process n times

I know this is similar to the code linked above though I want to be able to use illustrator instead of photoshop if possible.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source