how to get material color from wire color ?

Hi,
i’m using a script to randomize wire colors of some objects. And i’d like to assign them material with the colors randomized.
Is there a way to get the wire color of an object as a diffuse color for the mat ?
or is there a way to randomize the diffuse color of , say, a multi sub mat ?

Thanks

If you dont apply a material to an object it renders as a diffuse version of the wire colour, cant you just do it like that?

yeah if you wanted to do that you could do:


(
   for o in getCurrentSelection() do (
      -- Assign a random wirecolor
      local randomColor = color (random 0 255) (random 0 255) (random 0 255)
      o.wirecolor = randomColor

      -- Assign a material with the random color
      o.material = VRayMtl diffuse:randomColor
   )
)

Thanks cubiclegangster.
Unfortunately i cannot do like that because i would like to assign materials custom refl, refr, bumps, gloss…

Wow MoonDoggie,
you seem to script pretty fast and well. i’m an ass at maxscript. i know vb that’s all…
i will test this script.
Thank you

For your alternative approach, check out the random function of MasterBercon’s gradient map:

http://www.ylilammi.com/BerconGradient.shtml

With this you have options for random color per Material ID or Object. This option will also give you control over the spectrum the random colors are drawn from.

Very nice link
Thn k you very much