Notifications
Clear all

[Closed] Random material placement

Hey guys. Sorry, just started out with Max scripting. I wondered if anyone can help?

I’ve created a button that when pressed I need max to randomly select a material from the editor, say material 1-5 and place it on my object.

Is this very hard? I’ve had a look through the Max script help file and although I can find some useful commands I cant seem to string them together.

Many thanks in advance!

Tris

4 Replies

My MaterialMover scripts does that…

http://www.neilblevins.com/soulburnscripts/soulburnscripts.htm

Feel free to use the script, or if you still want to finish your script, feel free to steal any code you need.

  • Neil

Great, thanks. I’ll have a look. I’m pretty sure I will find it hard to decode your work as I’m completely new to this hehe. Give it my best shot though.

Thanks again.

Argh, tried to decode it but having no luck what so ever. Any chance you could point me in the right direction?

Cheers

Well, maybe this pseudocode will help…

  • First, you need a simple interface where you specify the start range and end range in the material editor, just two spinners. For this example, set them to 1 and 5.
  • For each object in my selection do the following
  • calculate a random integer between the start value and end value, call this x
  • my selected object.material = meditmaterial[x]

It can be as straight forward as that.

Another script you can piece apart is RandomMat, available here…

http://www.neilblevins.com/blurscripts/blurscripts.htm

This script is MaterialMover’s grandfather, and it’s a little more straight forward, it may be a better script to steal from for someone just starting out. Hope that helps.

  • Neil