ScriptSpot

Forum topic · General Scripting

Help with Assigning an array of object certain wirecolors

By Dannat121 · 2011-06-03

Description

Hi everyone!
I'm need some help with a script I'm working on for work. I don't really know how to tackle this since i'm pretty new at Maxscript. I have an array of objects that I would be selecting in a scene. This object count will change depending on how many objects I select. Now I want to randomly assign these selected objects with six different wirecolors (color 0 0 0) (color 145 28 177) (color 28 28 177) (color 88 199 225)(color 26 177 26) and (color 249 252 0). So basically I want object [0] in the array to have color 0 0 0 assign to it and so on until it hits the last color then it would repeat. So object 7 in my selection would have color 0 0 0 as well. Is this even doable? I know Max has a random function but it assigns the objects a color value from two sets of RGB values which is not what I want. If anyone has any suggestions it would be greatly appreciated.

Thanks!

Dan Hernandez

Comments (2)

Dannat121 · 2011-06-06

Hi Anubis,
Thanks for the quick response. Your script didn't hit the nail directly but it did give me enough info to get what I needed. In the end I ended up with this code block that is attached to this message. Thanks so much for your help! Without your suggestion I would have never been able to get it right.

Cheers!

Dan Hernandez

Attachments

Anubis · 2011-06-03

if i see, something like...

clrArr = #(black, white, green, red, blue, yellow)
objArr = selection as array

clrCount = clrArr.count
objCount = objArr.count

for c = 1 to clrCount do
	for i = 1 to objCount by clrCount do
		objArr[i].wirecolor = clrArr[c]