Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
query edge chain(s)
adamohern
Member, OS Professional Posts: 216 PRO
I'm creating a pipe command that sweeps a circular profile along an edge selection.
The opSweep function accepts edges or faces, but said edges must be contiguous. My command, on the other hand, should allow for both contiguous and non-contiguous edges. Contiguous ones would be federated into a single sweep operation, thus creating one continuous pipe along the selected edges. Non-contiguous edges would be treated independently.
Put another way, the edge selection should be grouped into islands of connected edges, and then each respective island will be swept independently of the others.
What's the cleanest way to go about this?
The opSweep function accepts edges or faces, but said edges must be contiguous. My command, on the other hand, should allow for both contiguous and non-contiguous edges. Contiguous ones would be federated into a single sweep operation, thus creating one continuous pipe along the selected edges. Non-contiguous edges would be treated independently.
Put another way, the edge selection should be grouped into islands of connected edges, and then each respective island will be swept independently of the others.
What's the cleanest way to go about this?
0
Best Answer
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,211You have to do some coding here -- I'm not aware of a clever shortcut that will partition your edge set into connected components.
For inspiration, one place to look is the findPath in our curve pattern example (it doesn't do the same thing you want, but it's the type of approach you might use): https://cad.onshape.com/documents/572e1daae4b085edae52bf83/v/a2245c2e80b488412955b46f/e/a8af7048d76cb1cc9a5ee25e
If performance is an issue, the fastest algorithm will go something like this:
1. Evaluate all edge endpoints for all edges into an array of points
2. Call clusterPoints (defined in vector.fs in std) on this array to find out the indices of coincident points
3. Use the returned information to compute the connected components: https://en.wikipedia.org/wiki/Connected_component_(graph_theory)#Algorithms
If performance (of this computation specifically) is not an issue (very rough guess is you expect <30 edges), it's slightly easier to code something where you maintain the array of connected components and process one edge at a time, either adding it to an existing component, creating a new component, or merging two existing components with it.
We should probably write something to make this easier...Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc6
Answers
For inspiration, one place to look is the findPath in our curve pattern example (it doesn't do the same thing you want, but it's the type of approach you might use): https://cad.onshape.com/documents/572e1daae4b085edae52bf83/v/a2245c2e80b488412955b46f/e/a8af7048d76cb1cc9a5ee25e
If performance is an issue, the fastest algorithm will go something like this:
1. Evaluate all edge endpoints for all edges into an array of points
2. Call clusterPoints (defined in vector.fs in std) on this array to find out the indices of coincident points
3. Use the returned information to compute the connected components: https://en.wikipedia.org/wiki/Connected_component_(graph_theory)#Algorithms
If performance (of this computation specifically) is not an issue (very rough guess is you expect <30 edges), it's slightly easier to code something where you maintain the array of connected components and process one edge at a time, either adding it to an existing component, creating a new component, or merging two existing components with it.
We should probably write something to make this easier...