sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    How to reverse edge

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 478 Views 4 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.
    • N Offline
      Nask
      last edited by

      Hello all,

      I have selected a array of edges that are all connected

      edge1 from point A to B
      edge2 from point B to C
      edge3 from point D to C
      edge4 from point D to A

      I like to change the edge3.end and edge3.start so edge3 is going from point C to D.

      I tried with reverse! and manually changing the edge3.end.position.x Y and z coordinates, but this doesnt work.

      I hope somebody can help me out.

      Background: I need to change the direction because in the rest of the code I animate something along these edges. If the 3rd edge is as it is now, animation is not OK.

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

        If it's a curve its vertices are returned in order, if it's a loop around a face ditto, so there's no need to 'sort' them ?
        However, assuming we can't do that...
        If you make the pairs of points (as [start.position, end.position]) into arrays you can match them and reverse them if needed - the 'hash' of the edges...
        edge1=[pA, pB] edge2=[pB, pC] edge3=[pD, pC] edge4=[pD, pA]
        Take first one ' edge1', we know that its ' points' array - points[0] is pA and points[1] is pB.
        Next we iterate through the rest of the hash and see if each item's points[0]==pB, if so be break the iteration as that's the next edge to use.
        If there's no match we know that maybe the next line's points are 'backwards', so we re-iterate the rest of the hash and this time see if item's points[1]==pB, if so be break the iteration as that is the next edge to use. In this example the ' edge3' points array is backwards and so it needs to be 'reversed' - using points.reverse! and then points[0] is pC and points[1] is pD...
        It there's still no match we have a line with no next line [an 'end']... ❓

        TIG

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

          If your edge is a line you can make
          menu edit / group it
          a rotation of 180Β° by the middle
          explode

          πŸ’š sorry i have not seen that i was in section developer 😳

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

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

            You want a sorting routine for connected edges?
            I got one on disk at home - but I'm currently in Germany on a field trip...

            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