How to programatically assign random colors to objects in 3ds max?
Asked
Active
Viewed 4,909 times
4 Answers
6
That works well if you just want to assign a random wire color. Here is some code for creating a standard material with a random diffuse color.
for o in $* do
(
m = standard
m.diffuse = random white black
o.material = m
)

cdiggins
- 17,602
- 7
- 105
- 102
-
Thank you very much for this. I didn't know how to do it! – relima Oct 26 '10 at 18:34
3
This is what I found online as a solution:
for o in $* do
(
o.wirecolor = random white black
)

relima
- 3,462
- 5
- 34
- 53
3
Various ways:
For wirecolor changes (i.e.-objects with no scene material on them) you can do,
(for mesh objects only)
for o in geometry do
(
o.wirecolor = random black white
)
for all scene objects you can do
for o in objects do
(
o.wirecolor = random black white
)
for all objects that are selected you can do
for o in selection do
(
o.wirecolor = random black
)
for only a single object, you can do
selection[1].wirecolor = random black white

Jonathan
- 31
- 1
0
for object that match a criteria use the where clause
for o in objects where <someproperty> == <somevalue> do o.wirecolor = random black white
so like..
for o in objects where classof o == Sphere and o.radius > 10.0 do o.wirecolor = random black white
or filter by the objects name then create and apply a standard material:
for o in objects where matchpattern o.name pattern:"Sphere*" do o.material = (standard diffuse:(random white black))

davet
- 117
- 1
- 1
- 6