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

    Merging two co-linear edges

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 1.3k 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.
    • thomthomT Offline
      thomthom
      last edited by

      Given a set of connected co-linear edges, you want to merge two of the edges.

      I have tried the "repair edges" method of creating a temp edge at the common vertex of the two edges and then erasing that edge. This results in merging more than the two edges connected to that vertex. It affects the edges connected to the edges connecting the vertex.

      I don't want to erase and recreate the two edges I want to merge, as it leads to problems when faces are connected. I could go on an recreate the edges as well, but then you're getting a very slow function - plus any Projected UV mapping will lose their Projection property.

      So are anyone aware of any way to merge two, and only those two, co-linear edges on a set of multiple co-linear edges?

      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

        Assuming you have checked that they are colinear, and you have a reference to the 2 edges e0 and e1...

        There are 3 vertices...
        vs=(e0.vertices+e1.vertices).flatten
        find the one that's shared by both edges
        shared=(e0.vertices & e1.vertices)[0]
        Check that ' shared' only has edges e0/e1 ...
        If so then fFirst another vertex
        start=(vs-[shared])[0] vec=shared.position.vector_to(start.position)
        Now make an entities transformation (assuming ents=e0.parent.entities)
        ents.transform_by_vectors([shared],[vec])

        If you could collect all such vertices and their vector adjustments but you might trip up by having deleted a vertex you are later transforming so I showed it in individual steps...
        this should combine the two vertices into one ?

        TIG

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

          Ah! Yes - that should work. However, one need to "heal" the zero length edge as well. (Creating a zero length edge in a group at the position of the zero length edge you want to remove, then explode the group - that will remove both zero length edges. Ugh, wish there was a nice way for this. )

          Doing it in bulk could be tricky - as you mention. Will see how I handle that.

          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

            I've adjust my example a bit because 'count' is not available in Ruby 1.8!
            It actually easier to do as I now show with []&[]...

            TIG

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

              As we have [or can easily get] a reference to this now zero length edge, presumably we can't successfully .erase! it ? Good if we could.
              The explode of a second zero length edge onto the vertex will auto-update and remove the rogue one anyway...

              TIG

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

                Yea, erasing the zero length edge would make a gap between adjacent edges. ...I think... might need to verify that again.

                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