Is it possible to randomize the active texture index of a given material with python.

I have an object with a single material that has 6 textures assigned to it. I want to randomize the active index, while deactivating the other 5. Is this possible with bpy?

here a snippet but maybe this is for BGE or you want do in multiple materials… not very useful right now


import bpy,random
mat = bpy.data.materials['Material']
tex = [1,0,0,0,0,0]
random.shuffle(tex)

for i,b in enumerate(tex):
    mat.texture_slots[i].use = b

Thanks, this is all I needed.