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.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 == ###..... 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
point1
andpoint2
are both matched to the iterator edgee
, in order to return atrue
match.
- 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
Advertisement