Reset color to average texture color
-
Sometimes we create a new material from a texture and want to set the material color to the average texture color.
We use to do this by setting the material color to nil.
new_matl.color = nil # use average texture color
But this stopped working.
However, we found a fix where if you set to color to itself after setting it to nil, it works ok again:
new_matl.color = nil # use average texture color new_matl.color = new_matl.color # this causes new color to be used properly
Go figure???
-
Why didn't you use
new_matl.color = new_matl.texture.average_color if new_matl.texture
in the first instance ?
-
-
Thanks,
Just the kind of advice I need. I'll go try it out.
... Seems to work great!
-
@thomthom said:
@al hart said:
But this stopped working.
When?
I don't know when it stopped working - sometime after I discovered that setting the color to nil did work (several years ago), and this past month when people started reporting bugs. (So of course, I suspected SU 8. But I just tried SU 7 and it fails there as well. So who knows...)
The bug was interesting, because the color looked OK in the SketchUp model until you saved and reloaded the model. However, the material editor showed that the material color was not set. When you click reset color it sets the color properly.
Advertisement