Sorting points in sequence

Hi, I am fairly new to grasshopper and I am having issues sorting the points in sequence as shown in the image. Would appreciate if anyone can help me as I have been stuck and have been trying for a few days now..

Current issue:

How I need it to be:

063025-sorting help.gh (12.2 KB)

You forgot to internalise points from Rhino via the right mouse button

Hello,

I just did but nothing changed and may I ask what internalising data do for my case?

The points will be stored in Grasshopp definition if you did it, pls updated the attachment.

I think I managed to solve it with the help of an old thread and some modifications…

Thank you!

2 Likes

Bit of a hacky way to do it (relying on either side of the decimal point for sorting each axis), especially if you end up needing more structured data later, because the columns are not distinguished. I suspect it will also get confused by very small separations in Y.

Here’s another way of doing it that sorts by X first, then uses a Create Set component to identify the unique X positions and the Map output (ie. which Set value does each List Item match?) to allocate each point to a tree branch for each X value. Then we sort each branch by Y. We can flatten that tree to get a contiguous list, or keep it as is if you ever need to operate on columns.


structured:

sort by x then y.gh (11.0 KB)
EDIT: Removed a superfluous graft->flatten leftover from earlier experimentation

4 Likes

I get in that sort of troubles on a daily basis, expecially when dealing with (usually imported) drawings that were exported/produced with bad tolerance

what happens is that all the points in each row/column are supposed to share the same x/y coordinate, but in reality they might differ by cents/thousandth of units, but because of that they look like jumping here and there to different rows/columns:

what I usually do, is to take advantage of Sort Points (specifically its index output) and I sort a ghost version of those points with rounded coordinates (here you can insert the degree of precision you want by eventually introducing a multiplier where the node is, in the example I did here it’s not necessary, but it all depends on the size of the array)

you don’t touch the original points, but just Sort a ghost version of those that has perfect sharp rounded coordinates, then just retrieve their indexes and use those to really sort your original points, something like this:

or just use an expression of some sort to save components on canvas (this expression trims the number of decimals to the amount set by the slider, then rounds to that):

Sort_imprecise_points.gh (12.6 KB)

3 Likes

Thanks Tom! I would have never thought about it this way, I will definitely check back in the future for reference on this!

Wow, thanks inno. This is insightful for my learning as I will never have thought about it this way and I will definitely try it in the future and use it as some form of a reference as well. Thanks!

Hey Tom,

You were right on needing a more structured data at a later time (now in my case).

I am studying your canvas provided however can I clarify what should be my output for the “Geometry Pipeline” in this case? I tried using both the outputs of points and coordinates to get it sorted by X followed by Y but it doesn’t seem to work.

Appreciate your help!

LH

Geometry Pipeline is a way of getting geometry from the Rhino scene without having to right click a Curve component and “select curves” etc. It lets you get realtime feedback on changes to the scene.

You type a layer name into the Layer box (you can use * and ? wildcards, so Walls* will return all objects from the layers Walls-Internal and Walls-Existing)

The icons along the bottom let you filter for points, curves, breps and meshes. Double click to turn them on and off.

In my example, the layer is set to * and the filter set to points so it should find all the points on all layers in the Rhino scene and output them. If your points come from some other GH graph, you don’t need it.

Thank you for the clarification, in my case then I’ll have to get the output from the geometry/point that I am trying to sort by X followed by Y into the components that you have come up with am I right?

Correct. My graph assumes a flat list of points, so if your point generation outputs some other structure you will need to either flatten it first, or potentially modify mine to account for it.

1 Like