applying color to circles?

applying color to circles?

Postby tomot » Wed Sep 12, 2018 9:01 pm

the following code draws 4 circles:

Code: Select all
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! :roll:
Code: Select all
color=Sketchup::Color.new(163,204,204)


TIA!
0

tomot 
PluginStore Author
PluginStore Author
 

Re: applying color to circles?

Postby Dan Rathbun » Sun Sep 16, 2018 7:38 pm

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.html

IF 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).
1
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: applying color to circles?

    Postby tomot » Thu Sep 20, 2018 6:40 pm

    Yikes! I should have been more descriptive.
    I'm trying provide a color to the faces of those 4 circles.
    0

    tomot 
    PluginStore Author
    PluginStore Author
     

    Re: applying color to circles?

    Postby TIG » Thu Sep 20, 2018 6:55 pm

    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...
    1
    TIG
    User avatar
    TIG 
    Global Moderator
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    cron

    Who is online

    Users browsing this forum: ivana14, vivek_dp and 12 guests

    Visit our sponsors: