• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Using add_line to automatically create a new face

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 2 Posters 582 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.
  • Z Offline
    ziocleto
    last edited by 1 Jun 2015, 16:56

    Hi all,

    first message here, nice to meet you all. I'm a newbie with sketchup but ok at programming.
    Now my question is:

    let's say I have built a piece of geometry, which is beautiful,

    From Sketchup UI:
    Adding just 1 line (from point A to point B) skectchup auto-generates a new polygon.

    From Ruby script API:
    Using the same points A,B and using entities.add_line ... or add_edges etc there is indeed a line appearing in the model but it doesn't auto-generate the polygon.

    How can I auto-generate a polygon from the same configuration in the Ruby API?

    Cheers

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 1 Jun 2015, 17:28

      entities.add_face(args)
      Where 'args' is a variety of things - e.g. a list or an array of [ordered] vertices or points or edges...
      You might get those from a polygon/circle or your own added edges: but with points the edges are generated by the passed array.
      http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_face
      To make all faces that an edge can support, try using edge.find_faces
      There are many ways to achieve what you want...
      It depends where you start...

      TIG

      1 Reply Last reply Reply Quote 0
      • Z Offline
        ziocleto
        last edited by 1 Jun 2015, 21:09

        Hi TIG,

        I've tried entities.add_face(args), which is how I create geometry normally. But the problem I have is more subtle.
        It's the different behaviour between adding a line in sketchup (UI from mouse) and adding the same line from API call.

        If I draw the same line with the same points in sketchup (UI from mouse) on that particular piece of geometry it adds automatically a face (polygon), which is the intended result and it's correct.

        If I call entities.add_face(edge) from ruby API either I get an error (too few parameters, at least 3 edges) or if I use entities.add_line(pointA, pointB) or entities.add_edge(pointA, pointB) it draws a line/edge but fails to create the face (polygon), which is not the same behaviour that I have if I do it manually with the mouse.

        So is there a soft of global function to set to automagically create faces in those circumstances form API?

        1 Reply Last reply Reply Quote 0
        • Z Offline
          ziocleto
          last edited by 1 Jun 2015, 21:24

          Sorry it looks like it's all working fine now.
          I'm not quite sure what triggered it work maybe quitting sketchup and reloading it after a long session fixed it.

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 1 Jun 2015, 21:25

            To repeat from my previous post...
            To make all faces that an edge can support, try using edge.find_faces
            If that edge can form a face [or faces] then the face[s] get added to the same context...

            TIG

            1 Reply Last reply Reply Quote 0
            • Z Offline
              ziocleto
              last edited by 2 Jun 2015, 10:56

              Thanks I've missed that edge.find_faces, it works great.
              I think the naming put me off as I wasn't expecting that it will also add faces, I just thought it was going to find potential faces, I think it should may be renamed: find_and_add_faces just for clarity.

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

              Advertisement