Deleting an Edge knowing 2 points
-
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
-
Assuming all of these edges are inside a
group.entitiescontext...
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 == ###..... etcetc
}`
-
.
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
point1andpoint2are both matched to the iterator edgee, in order to return atruematch.
- I prefer the boolean finding test to ensure that
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement