Script to Automaticly change layer

hi.
I am new to phyton, but we are using rhino to nest our parts. the problem is that we have to change the layer of each surface, before sending it to the cnc. for example, if i have a piece, i need the virtical surfaces to be in “layer 1” the holes to be in “layer 2” and so on. and it’s a lot of work, to first explode the piece, and then change the layer of each surface every time. this task seems to be perfect for a script. can enyone point me in the right direction to write such a script?

best regards . Mark

You could use the rhinoscriptsyntax.CurrentLayer function.

Edit: rhinoscriptsyntax.ObjectLayer might also be relevant to your problem.