[Closed] Convert text string into color?
I’m working through a sort of generic loop for materials (Think of it like the blur DO script, only for material issues) and its working well, but i’m running into an issue that i can’t seem to work through. can’t for the life of me find anything in the docs that helps and old trial and error is failing so far!
Namely, how to convert a text field into a color…
(print $.mat.Diffuse_Color)
prop = "Diffuse_Color"
valueClass = Color
--for any of these vals..
val = "[255,255,255]"
val = "color 255 255 255"
val = "(color 255 255 255)"
val = "point3 255 255 255"
setproperty $.material prop (val as valueClass)
What would be ideal would be if there was a way to specify this
color value in the text field so that it would convert with an ‘as color’ statement… as that works perfectly with the Floats/Integers/Booleans and if i could add in color that would cover something like 98% of the options in a material.
Or else, what to look at to modify the actual UI of the floater to be a color picker instead of a text field when a category that has a valueClass of Color is selected?
Thanks,
Dave.
val = "[255,255,255]"
col = (execute val) as color
val = "color 255 255 255"
col = execute val
val = "(color 255 255 255)"
col = execute val
val = "point3 255 255 255"
col = (execute val) as color