Apply random material to element
I found on this forum the following script that works very well when applying a random amount of materials to selected objects
Now if I have a single mesh with many sub objects in it (cubes for example) that each can be selected with the mesh / element selection, how shall I modify the script to make it apply the random materials to the elements of the mesh?
I presume the "obj" should be swtiched to become refering to the element instead?
for obj in selection do obj.material = meditMaterials[random 1 4]