Reorder points

Hi Everyone,

I’ve been using Revit Dynamo lately to tackle a specific problem, and I’m wondering if there’s a way to sort points in some manner that would allow them to be properly connected.

Specifically, I’m looking for a function that enables the sorting of points in a specific direction (e.g., left to right or top to bottom), and then connecting these sorted points to create a line or polyline element.

I’ve experimented with various Dynamo functionalities so far, but haven’t found a solution that fully meets my expectations. Any help and ideas would be greatly appreciated!

Thanks in advance!

You might need to elaborate further what these “expectations” are there are a lot or or’s in the function you specifically want.

You can sort points in pretty much any way you’d like, but the specific ‘how to’ requires understanding the logic which you’re after.

  • X value
  • Y value
  • Z value
  • Parameter along a curve
  • Distance from a point
  • Angle from other point when both points are taken as vectors.
  • Whatever else’s you can think of

These can also be combined as desired (i.e. grouping and sorting by angle from the X axis then distance from the center).

The hard part of this (as @pyXam pointed out) is that the reason to use any one sorting method will depend on what you’re actually after. I might guess that the actual order of points you wanted in your screenshot was [0,1,2,3,5,6,4]. If so you can try this:

  1. Draw a circle by best fit though the point group.
  2. Use a Curve.PointAtParameter node to find the parameter of each point on the circle.
  3. Use a List.SortByKey node to sort the points by the parameter values.
  4. Draw the polycurve though the sorted group.

Depending on how the circle was drawn (and so really the base points and their relationship to the global coordinate system), this could be sufficient. In other cases you might need to use an alternative method.

All of that said, I find that most of the time when we see points collected like this there is a better way to get to the data you are after (i.e. if these were extracted from floors you can use the curve loop directly).

Yes, the correct order would be [0, 1, 2, 3, 5, 6, 4]. I worked with planes fitted to points and vectors associated with them as you see on the pic. However, the List.SortByKey function does not run properly.

Set the list and keys to @L2 and you should be all set.

1 Like