Collect Curves in chain

Hello Dynamo Community,
I have created geometry from an image but I would like to collect the chain of curves and remove the branches. I don’t know if it’s possible to check the curve and see if it’s connected to another curve to create a chain. Has someone written a node or python for such an algorithm?

Image of what I’m trying to solve.

I guess writing your own algorithm wouldn’t be too difficult assuming that pattern is always the same:

  1. Evaluate all curve endpoints and check for coincidence with all others.
  2. Cull any curves which don’t have two coincident points
  3. Create a polyline from those that do, and collect the leftovers from its endpoint

Shortest path node in Lunchbox should make quick work of this.

1 Like