Scripting to automate rhino workflow for Texturing

Hello everyone!

I would like to consider automating my rhino a little bit to speed up my workflow,
my first idea was to create a script that automatically selects all the layers and assign a random material to each of them.
I want to do this because I could save time with high geometry count models, instead of assigning them one by one.
It is a requirement of my rendering software Lumion12, that to assign a material, the model in rhino needs to have a material assigned.

where should I start with trying to implement this? I am confident in my ability to use python but has anyone else made a similar program, what rhino libraries are available for this type of work.

Kind regards.
Jason