• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Applying color to circles?

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 5.0k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    tomot
    last edited by 12 Sept 2018, 20:01

    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!

    [my plugins](http://thingsvirtual.blogspot.ca/)
    tomot

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 16 Sept 2018, 18:38

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

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomot
        last edited by 20 Sept 2018, 17:40

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

        [my plugins](http://thingsvirtual.blogspot.ca/)
        tomot

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 20 Sept 2018, 17:55

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

          TIG

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            1/4
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement