Material Zones to random Vertex Colour script (for creating ID Maps)

I’d like to turn all material zones of my model into a random vertex colour, akin to making an ID Map. While this can be done manually, I’m sure this is better suited for a script. Does something like that exist? Currently I’m doing the following:

  • enter Edit Mode
  • select first material
  • switch to Vertex Paint mode
  • pick a random colour
  • paint (SHIFT + K)
  • rinse and repeat

This would make my Substance Painting life a little easier. If there’s a script you know of, or someone who can code this for me, please let me know. Thank you!