[ruby] material colorize
-
I'm testing a small tool to temporary turn all colors, for any material containing a texture, to white. Together with a shaded style this results in a black and white representation of the model.
model = Sketchup.active_model materials = model.materials materials.each {|m| m.color = [255,255,255,255] }
Annoying thing is: if you run the code, SketchUp is checking the 'colorize' flag (see pic) for the materials which can't be unchecked with code when reverting back to the original settings.
Already found some topics about this behavior:
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=49184%26amp;p=442077%26amp;hilit=colorize#p442077
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=22488%26amp;p=189349%26amp;hilit=colorize#p189349The topics are rather old - any new ways to prevent this OR to uncheck the colorize flag by code?
-
As of SU2015 you can get and set the colorize properties: http://www.sketchup.com/intl/en/developer/docs/ourdoc/material
-
Thanks, I already used that method for reverting to the original settings.
Had another look...turns out I just have to add 'm.colorize_type= 0' when setting everything to white to prevent SketchUp to automatically use the colorize option.
-
do you really need to tamper with textures?
I just use rendering options to output a series of different styles...bit like this...
@start = [] @start << Sketchup.active_model.rendering_options["FaceFrontColor"] # templates default @start << Sketchup.active_model.rendering_options["RenderMode"] # templates default def change_color Sketchup.active_model.rendering_options["FaceFrontColor"] = 'white' # or use # (Sketchup;;Color.new(255,255,255,255)) Sketchup.active_model.rendering_options["RenderMode"] = 5 #monochrome end def revert_color Sketchup.active_model.rendering_options["FaceFrontColor"] = @start[0] Sketchup.active_model.rendering_options["RenderMode"] = @start[1] end
john
-
Oh - good point. Are you making everything 100% white? I thought at first you wanted to desaturate and lighten the textures.
But if you only going to make everything white then rendering options is the way to go - no messing with the undo stack etc. -
I use the tool to quickly switch two modes: textured / colored AND grey scale
I have a fully textured 3d model and a sectioncut with faces in several shades of grey. In layout I need a grey scale representation without textures. The grey scale colors of the section cut must be preserved.
So the tool temporary converts the colors to grey scale, makes the material color for those materials with a texture to white and sets the style to shaded.
Previously I needed two scenes in SU and one extra layer in LO to achieve the same result in LO.
Advertisement