Applying color to circles?
-
the following code draws 4 circles:
mod = Sketchup.active_model ents = mod.active_entities sel = mod.selection face = sel.grep(Sketchup;;Face)[0] locations=[@pt1,@pt2,@pt3,@pt4] locations.each{|loc| @pt1=loc ents.add_circle(@pt1, @vec3, @dia, 24)
What code do I need to apply a single color to each circle?
I'm looking at http://ruby.sketchup.com/Sketchup/Color.html for inspiration,
but I'm not able to make the code work!color=Sketchup;;Color.new(163,204,204)
TIA!
-
In order to see colored materials for faces, the rendering options (style) must be set to either "shaded" or "shaded with textures". See the RenderingOptions class:
http://ruby.sketchup.com/Sketchup/RenderingOptions.htmlIF you are painting the circle's edges, then in order to see the edges colored, the EdgeColorMode by be set to "ByMaterial" rather than "AllTheSame" (black).
-
Yikes! I should have been more descriptive.
I'm trying provide a color to the faces of those 4 circles. -
Your current 'circle' code only draws some edges [all be it that they are in the form of circles].
Use e.g.
edges=ents.add_circle(@pt1, @vec3, @dia, 24)
Then make a face for one of those edges...
ents.find_faces(edges[0]) face=edges[0].faces[0]
Then add a material to the 'face'...Of course this is very simplistic...
e.g. if your circles might overlap etc not all edges might get a face, so then you probably need to make each circle/face inside its own group in turn, at least until you have finished making/painting it etc, after which exploding the temp-group can put the faces back into the desired entities-context...
Advertisement