sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Problem while creating a circle ?!

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 263 Views 2 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.
    • M Offline
      Morgan74
      last edited by

      Hello everybody,

      I'm trying to draw and paint a circle in the center of a Face, so here is my code :

      The current selection is a Face :

      
      center = Sketchup.active_model.selection.first.bounds.center
      normal = Sketchup.active_model.selection.first.normal
      outline = Sketchup.active_model.entities.add_circle(center,normal,10)
      circle = Sketchup.active_model.entities.add_face(outline)
      circle.material = "red"
      
      

      This code draw a circle but "add_face" always return nil so I can't paint in red this new circle !??
      Can't you help me please, because I don't understand the problem?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Since you are drawing onto a face, when you try to make a face from the circle edges, there is already one there, and unfortunately it returns nil if it does not create a new face.

        ` face = Sketchup.active_model.selection.first # Keep track of the original face
        center = face.bounds.center
        normal = face.normal
        outline = Sketchup.active_model.entities.add_circle(center,normal,10)

        assume that the circle edges borders to the new circle and the original face

        circleface = ( circle.first.faces.to_a - [face] ).first
        circleface.material = "red"`

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • M Offline
          Morgan74
          last edited by

          Thanks a lot for your reply!!
          It's really better now !!
          But with circleface = ( **outline**.first.faces.to_a - [face] ).first

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            ooops! 😳

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

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

            Advertisement