sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to detect duplicate edges?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 364 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.
    • RichMorinR Offline
      RichMorin
      last edited by

      I'm adding some edges to a model, in places where I really don't think it already has any. However, when I try to save the model, SU complains about duplicate edges, as:

      
      Results of Validity Check.
      
      CEdge (3749) and CEdge (3750) connect the same 2 vertices - fixed
      CEdge (4122) and CEdge (4123) connect the same 2 vertices - fixed
      
      

      I have tried a couple of hacks at discovering how I might be doing this. My current code looks like this:

      
      pph = {}
      loop, generating point pairs to define edges
        ...
        ppt = "#{ [ p1, p2 ].inspect }"
        puts "1; #{ppt}" if pph[ppt]
        pph[ppt] = true
      
        ppt = "#{ [ p2, p1 ].inspect }"
        puts "2; #{ppt}" if pph[ppt]
        pph[ppt] = true
      
        ents.add_line(p1, p2)
      end
      
      

      This doesn't print anything; suggestions, anyone?

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

        what's the scale of the stuff you draw? Maybe it's too small for SU to tell the difference?

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

        1 Reply Last reply Reply Quote 0
        • RichMorinR Offline
          RichMorin
          last edited by

          If I could print out the vertices for the edges SU is complaining about, I might be able to tell if it's a scale issue.

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

            You can use a text leader to point to each troubled vertex. I'm not sure how you would determine which ones were troubled before fixing them though... ๐Ÿ˜•

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

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

              If I understand this correctly, you are adding edges to entities from a 'list' of points.
              Afterwards you are getting errors about some edges sharing pairs of vertices.
              It's very common the 'remake' new edges on top of existing edges, so why you get errors seems mysterious.
              ...
              newedges=[]
              ...
              newedge=ents.add_line(p1,p2)
              ...
              Keep a list - array/hash of the new edges as you go...
              newedges<<newedge
              ...
              When you make a new edge you already know its start/end point.
              Check any already made newedges to see if they have the same start/end positions OR end/start positions: then if they do report clash, or don't make the newedge etc...

              TIG

              1 Reply Last reply Reply Quote 0
              • RichMorinR Offline
                RichMorin
                last edited by

                TIG-

                If you'll look at my code extract, you'll see that I'm already doing what you suggest. pph is a hash of "point pairs", indexed by the vertex positions (encoded as strings, to avoid object issues).

                However, my code isn't detecting any clashes, even though SU does (later) when it tries to save the model.

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

                  @richmorin said:

                  TIG-

                  If you'll look at my code extract, you'll see that I'm already doing what you suggest. pph is a hash of "point pairs", indexed by the vertex positions (encoded as strings, to avoid object issues).

                  However, my code isn't detecting any clashes, even though SU does (later) when it tries to save the model.

                  That's why I suggested instead of inspecting the points you inspect the edges already made...

                  TIG

                  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