Finding 'Open-end' Edges

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Finding 'Open-end' Edges

Post by paullee »

Thinking how to find edges in a Sketch which are 'open-ended' - e.g. see highlighted edges below.

[EDIT - not necessarily a Sketch Object, but maybe say a list of Edges]


1. The 2 end edges for the wire on the left
2. The edge within rectangle

3. After finding those 'open-end edges', they are removed, and find if there are still 'open-end edges
4. Now the remaining edge in the middle of the wire on the left is found 'open-end'
(and should be removed further then).

Thanks for any idea :)

Test_ ArchSketch_ 44_ Open-End Edges.FCStd
(4.66 KiB) Downloaded 61 times
Screenshot from 2021-10-02 00-36-43.png
Screenshot from 2021-10-02 00-36-43.png (213.58 KiB) Viewed 2653 times
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: Finding 'Open-end' Edges

Post by chrisb »

The edge on the right side with the point-on-object constraint is complicated, because it doesn't enforce to lie between the endpoints. While exactly this condition can be checked with straight lines, it can be a problem with arcs.
All three lines have the same set of constraints; are they all open-ended or none of them or only the lower two?
Attachments
SnipScreenshot-dd5eb8.png
SnipScreenshot-dd5eb8.png (6.37 KiB) Viewed 2604 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: Finding 'Open-end' Edges

Post by paullee »

chrisb wrote: Fri Oct 01, 2021 5:33 pm The edge on the right side with the point-on-object constraint is complicated, because it doesn't enforce to lie between the endpoints. While exactly this condition can be checked with straight lines, it can be a problem with arcs.
All three lines have the same set of constraints; are they all open-ended or none of them or only the lower two?
Thanks for bringing up this situation.

In fact, for clarification, I assume all the edges with intersection would be broken up - like the topic 'Creating a Puzzle' by running Boolean Fragment in https://wiki.freecadweb.org/Part_Slice

Maybe I make an model based on your example... :)

So only the sector (or is it another term) on the top should remains.
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: Finding 'Open-end' Edges

Post by paullee »

'Fragments' highlighted 'alternatively.


Test_ Sketcher_ BooleanFragment.FCStd
(7.97 KiB) Downloaded 56 times
Screenshot from 2021-10-02 01-53-24.png
Screenshot from 2021-10-02 01-53-24.png (212.17 KiB) Viewed 2571 times
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: Finding 'Open-end' Edges

Post by paullee »

Maybe alternatively, those edges which can enclose / form a face can remains, other to be discarded.
jbi
Posts: 117
Joined: Sun Apr 24, 2016 3:28 pm

Re: Finding 'Open-end' Edges

Post by jbi »

Hi,
I do something similar with wires. You can use the vertex information , if a vertex occurence is 1 it must be a single ended edge. I guess you can use the vertex.isSame or some of the identity functions for comparing. I did it with creating a list of hashcodes. I dont know how sketches behave and if it creates a wire. But i guess you can use the vector information as well and calculate distances between the vectors, but it will be much slower if you have a big number of edges.

best regards jbi
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: Finding 'Open-end' Edges

Post by chrisb »

jbi wrote: Mon Oct 04, 2021 6:20 am You can use the vertex information , if a vertex occurence is 1 it must be a single ended edge.
That doesn't work for the example with the line endings on the arc from above.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
ragohix769
Posts: 568
Joined: Sat Jul 18, 2020 7:04 am
Location: Rome - Italy

Re: Finding 'Open-end' Edges

Post by ragohix769 »

Here are too some suggestions on how to approch the problem:

https://forum.freecadweb.org/viewtopic. ... 92#p527492

(IMHO, not yet solved, especially if you read the last message by me... The checker, IMHO, it's not so useful to find open vertex and helping closing where needed)
After #ElonMuskBuyTwitter I'm no more on Twitter, that's really enough :-(
=> Now you can find me here on #Mastodon: https://mastodon.uno/@opensoul - I hope more people do the same :-)
paullee
Veteran
Posts: 5118
Joined: Wed May 04, 2016 3:58 pm

Re: Finding 'Open-end' Edges

Post by paullee »

Thanks all for the suggestions :)

Not sorted out yet, though I am thinking to use Part.getSortedClusters (or Part.sortEdges ?), to check the first and last edges if they are closed, vertex are of single occurrence, isSame() may be useful ...

BTW, any idea how to use hashcodes ?

Thanks for any idea !
Post Reply