How to detect duplicate edges?
-
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?
-
what's the scale of the stuff you draw? Maybe it's too small for SU to tell the difference?
-
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.
-
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...
-
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-
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.
-
@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...
Advertisement