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

    Deleting an Edge knowing 2 points

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 373 Views 3 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.
    • K Offline
      ktkoh
      last edited by

      My Dovetails Tail program sometimes leaves faces that should have been deleted by the pushpull action. I am trying to clean these up by deleting edges for which I know only the end points. I have not been able to find a way to identify the edges knowing only 2 points so I could delete them.

      Keith

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

        Assuming all of these edges are inside a group.entities context...
        Iterate to extract edges that at least match the length between the points...
        length = point1.distance(point2) poss_edges = group.entities.grep(Sketchup::Edge).select{|e| e.length == length } the_edge = nil poss_edges.each{|e| if (e.start.position==point1 || e.start.position==point2) && (e.end.position==point1 || e.end.position==point2) the_edge = e break end }
        Now you have the edge with a starts|end matching the two points.
        If you gave a number of pairs of points as an array of two element arrays, then iterate those in turn:
        ` points.each{|ps|
        point1=ps[0]
        point2=ps[1]
        length == ###..... etc

        etc

        }`

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          .
          Here is TIG's code altered a bit, and wrapped in a method:

          
          def find_edge(
            ents,   # a Sketchup;;Entities collection
            point1, # a Geom;;Point3d for start position
            point2  # a Geom;;Point3d for end position
          )
          # Returns the first matching edge found, or nil if no match.
            #
            length   = point1.distance(point2)
            possibly = ents.grep(Sketchup;;Edge).select {|e|
              e.length == length
            }
            found = possibly.find {|e|
              spt = e.start.position
              ept = e.end.position
              (spt==point1 && ept==point2) ||
              (spt==point2 && ept==point1)
            }
            #
            return found # nil if no match
            #
          end
          
          • I prefer the boolean finding test to ensure that point1 and point2 are both matched to the iterator edge e, in order to return a true match.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • K Offline
            ktkoh
            last edited by

            Thanks TIG and Dan

            I applied the code to the Tails part of my Dovetail Tool and now the result is a part with tails that is still a solid. No left over edges or faces.

            The strange thing was that when selecting the component edges if you selected them clockwise (edge1 to edge2) the part was clean but selecting in a counter clockwise direction there were left over faces. Now thanks to your help edge selection direction works either way.

            Thanks
            Keith

            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