C# dataTree - merge value by path


I was wondering how to merge values in a same path by C# script.
In the dataTree that I attached in this post, I wish to reconstruct the datatree by merge polylines in the same path, for example :
Branch 0 : (0,0), (0,1), (0,2)…(0,8)
Branch 1 : (1,0), (1,1), (1,2)…(1,8)
Branch 2 : (2,0), (2,1), (2,2)…(2,8)
Branch 3 : (3,0), (3,1), (3,2)…(3,8)
Branch 4 : (4,0), (4,1), (4,2)…(4,8)
Branch 8 : (8,0), (8,1), (8,2)…(8,8)

Does anyone have any advice for me?
Thanks a lot!

DataTree_mergeByPath.gh (12.8 KB)

Your stuff can’t been joined via the classic R Curve.JoinCurves(joinSet, tol); Method (blame overlaps, Karma, no espresso around etc etc).

Polyline_Join_V1.gh (14.4 KB)

BTW: What means “merge” to you for this occasion? Maybe do Curve/Curve Ccx (all VS all) and get the resulting BrepFaces? (or Polylines). Or find the overlaps and attempt to join what is possible? Or some other?

BTW: Maybe by merge you mean union? If so see this

Polyline_Union_V1.gh (12.3 KB)

Or better this:

Polyline_JoinOrUnion_V1.gh (261.6 KB)

Q: Are these Mesh Outline (shadow) polys?

1 Like

This is exactly what I was looking for! thanks for the script!
About your question,
Q: Are these Mesh Outline (shadow) polys?
: yes! it is the result outlines from mesh shadow :smiley:

Forgot to add the crv.IsClosed + crv.IsPlanar(tol) tests. Since you should write stuff ALWAYS having bananas input in mind, add them for the record.

1 Like

Perfect, your script has many factors that I did not know/consider before (even try/catch statement). It was a great help for me to make a proper script. Thanks a lot!!