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

    Switch direction of edge?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 5 Posters 325 Views 5 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.
    • C Offline
      cjthompson
      last edited by

      Is there any way to switch the start and end of an edge? I noticed that many times, loops don't go start to end/start of next line(see examples):

      What I expected.

      What the edge directions actually are.

      It also seems to mess up with Loop.convex?().

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        I suggest you look into Weld.rb and several other tools that use similar code to order the vertices in a loop - it's a bit convoluted but 'order_points' is a vital part many scripts...

        TIG

        1 Reply Last reply Reply Quote 0
        • pilouP Offline
          pilou
          last edited by

          Copy 180° rotate it then kill the original?

          Frenchy Pilou
          Is beautiful that please without concept!
          My Little site :)

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            Yeah, its not possible through the API. Instead you have to figure out the order on your own and track them in a an array or set or hash or something.

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

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

              As Chris, I write my own routines into the script to sort the edges/vertices..

              Edge.reversed_in? is useful, as well is the EdgeUse class.

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

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                IF the edges are coplanar and they either bound a face or can be given a face, then you can get the face.vertices and these always return ordered and in the same direct relative to the face.normal - counterclockwise if my memory serves we well...
                You can then use these vertices to get an array of ordered points to redo a set of edges so they are all the same direction... I've been thinking of a quick fix where you clone the face.edges into a group from this etc...
                You need to delete the old edges and remake the face etc
                It could be a quick way to make curves too...
                For 3D edge collections it's a slog through the edges and sorting them as Chris says - I believe that it was RickW who was the first to come up with a method for this - as seen in weld.rb ...

                TIG

                1 Reply Last reply Reply Quote 0
                • C Offline
                  cjthompson
                  last edited by

                  TIG's method of getting the vertices of a face worked for me.

                  Thanks everyone for the replies.

                  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