Sort Families Along Polyline

I am trying to sort a series of families in counter clockwise order.

I have found a “sort points as Perimeter” node in a package but the series gets screwed about when there is a step back.

I am looking for a better solution to sort the families along the floor slab edge Polycurve.

Any advice is appreciated!

Hi @dhughesJ3ZSS,

Have you tried this approach:

This method sorts the Points according to the parameter value of the polycurve.
So if a point’s “closest point on the curve” towards that point is near the start, it will be sorted in front of points near the end. Like this:

However this does not necessarily mean the points will be sorted counter-clockwise, just by their distance along the curve.

2021-05-26 SortPointsAccordingToCurveDistance.dyn (13.1 KB)

PS: maybe the list lacing needs some tweaking (because i didnt feel like creating the points and curves and testing it).

1 Like

@Daan weave in the line direction node :slight_smile:

How do you mean Marcel?

It will tell you if it is clockwise or not, given the plane it is in, taking into account on what relative coordinates its in

1 Like

Instead of a list.sort, an index of, and a list.indexof, perhaps try a List.SortByKey node?

1 Like

I have tried the method you have provided with no luck. The key here is that I need them to be sorting in order as displayed in my screen shot.

For now I think I will just rename the unordered points and revisit this topic later.

I have found a “sort points by curve” node from Proving Grounds use to exist but it sounds like they have discontinued their dynamo services. bummer.

Can you provide a data set so we can illustrate how this is done? The method @Daan showed above has worked for me consistently for about 5 years now.

Sort_Example.rvt (3.7 MB)
Sort_Example.dyn (31.2 KB)

The help is very much appreciated

Rebuild the curves as PolyCurve.ByPoints and you will get a more accurate point closest to result. I think that is the step that is missing and causing problems.

There were a few issues I outlined here, with a fix for the graph as you provided it.

The connections are falling on top of eachother at the corners, which is throwing off the sorting. Building a polycurve by consecutive points (as @simon_murphy1 indicated) may resolve this. Alternatively using a shape which respects the corners cleanly. Would likely take a lot less time to draw that as a filled region that number these by hand.