How to sort a list of points along a localised plan


I’m trying to sort a list of points and connect the sorted points with a line, the file isn’t located between the default between X, Y, Z but instead I want to sort the points on localised constructed plane.

localised plane:

GH Script: (21.3 KB)

You don’t want to sort points for this. You want to understand data trees and write cleaner code.

  • I disabled some unused components and moved them off the top of the canvas.
  • I added a yellow group to limit the number of extended lines to only those that intersect the rectangles.
  • I added the white group to get the intersections and split the long lines to get the short lines you want.

This is far from the only way to do this, you might want the results to be organized differently, such as all the short lines being in branches that correspond to the rectangles? But it’s late, I’m out of time. (33.5 KB)

P.S. Oh look, that was too easy. Just added Flip Matrix (purple group): (32.5 KB)


The picture suggests the requested lines are between the rectangles, not inside ?
A simple invert and two Cull Index do the job. (32.1 KB)


Oh yes, thank you. It can be fixed with only one Cull Index.


I noticed another thing last night but was too beat to fix or explain it. If you connect ColorJ (list items) instead of ColorB (branches), it’s clear that the lines in each branch are not in sequence.


This is easily fixed using Sort Along Curve (orange group) on the base points used to create the long intersecting lines.

I couldn’t resist some additional refactoring of this code… I changed the way the crosscut line is created (the source of the base points) and replaced the “Localised Plane” with X and Y vectors from the perimeter line segments I had used. (cyan group) I then deleted all the unused code. (34.4 KB)

Click the image twice to see it full size. Not sure why the GH code file is bigger?

1 Like

Thank you both for taking a look at the script, it’s been a massive help and very insightful!

I just have one more question, I’m also trying to split the multi-coloured curves with the white points seen in the first image below.

But when using list item to select a specific curve within the data trees, it’s also extracting a segment which isn’t being sub-divided. It’s not a huge issue as I can simply cull the item, I’m just curious to know why it’s happening?

I’m using the Curve I Curve component to extract the interacting points between the two curves which I assume is the culprit.

GH script: (43.7 KB)

I don’t recognize your V2 code as what I sent this morning? And don’t have the stamina to wade through it all again. I believe I understand the issue and will sleep on it. Too many other things at the moment.

I started with my file from this morning and added a couple bits. This is difficult because the first and last rectangle must be treated differently from all the others, and from each other. :thinking: So the rectangles must be sorted in sequence, like this: (deep purple group)

The I split the rectangles using the intersection values I already had: (gray group)

Finally (for now), I added a copy of my ‘Tree/List Viewer’ tool to examine the fragments: (47.8 KB)

I’m too busy to do anymore right now, maybe Monday morning.

P.S. What about the short segments between the line pairs?

1 Like

I think I got it? (48.2 KB)


Hi Joseph,

Yes that was the issue I was trying to resolve! Thank you for taking the time to looking this, your solutions have been very insightful!

It looked complex at first. The solution I ended up with (gray group) didn’t require the rectangles to be sorted, so the purple group could be deleted. Still, it’s nice to have tidy geometry.


1 Like