[Closed] How to randomly assign material on a specific count of objects ?
Hello everybody.
I search a way to randomly apply some material on some objects.
I have 54 objects and 6 materials (6×9 = 54. I guess you understand )
I want to randomly select object 9 by 9 and apply a material in each time. Of course the objects that already be select and get a material can’t be select again.
All of the objects already have a material on it. I think to freeze the objects i select and test the freeze to avoïd this object be selected again. And when all objects has changed material, unfreeze all.
Someone has an idea to make it ?
Thank you for your help guys
Hi Bruno,
You can use something like this:
for i = 1 to selection.count do selection[i].material = meditMaterials[((i – 1) / 9) + 1]
Light
Oh god.
I think i always learn something in maxscript.
I don’t know the selection[i].
Thanks a lot Light.
Your help is very useful. I tell you if i success
That’s works, that’s works
Thank a lot Light.
Could explain me your line of code. I don’t understand it a lot.
Thank you again
cool!
and what if I want to assign randomly to any count of object ??(imagine a crowd clothes colors)
It basically loops through your current selection and assigns materials from 1 to 6. You can see that “((i – 1) / 9) + 1” creates values from 1 to 6 throughout the loop.
for i in selection do i.material = meditMaterials[random 1 24] would do what you need Laurent.
Light
ok I got it by myself, thx!
But how can I specify the material range with a spinner or something?
rollout forege “random material”
(
label label0d “this tool apply random materials”
label label1d ” from MaterialEditor to selection.”
button un ” RANDOMIZER – 6 materials “
on un pressed do
(for i = 1 to selection.count do selection[i].material = meditMaterials[random 1 6.0]
)
button deux ” RANDOMIZER – 10 materials “
on deux pressed do
(for i = 1 to selection.count do selection[i].material = meditMaterials[random 1 10.0]
)
button trois ” RANDOMIZER – 15 materials “
on trois pressed do
(for i = 1 to selection.count do selection[i].material = meditMaterials[random 1 15.0]
)
)
createDialog forege width:220 height:130
Or check the RandomMat script available here:
http://www.neilblevins.com/blurscripts/blurscripts.htm
- Neil
Laurent,
Just add a spinner control like: spinner toVal range:[1,24,6] and then use toVal.value instead of max values like random 1 toVal.value
Light