Ordering brep faces

Hello, I am trying to sort these faces into an orderly pattern. Rite now faces are not arranged in order. I tried to sort center points by x and y coordinates using sort key component but failed to sort these surfaces. Can you please guide me how can I get all these faces in order.

Thank you.

Please upload Gh file with internalize data.

Here is a trick to sort points in X then Y …

parlellogram grid.gh (13.5 KB)

parlellogram_grid_re.gh (15.4 KB)

hope it helps~


These are the point locations of the surface centroids in the file you uploaded. As you can see, if you use them directly as a sorting criteria you get undesired results.

By rounding the centroid values, you can get the desired sort result.

parlellogram grid_re_kr.gh (18.5 KB)

The method provided by @parametriccuriosity works with the file you provided, but there are times it can produce unexpected results.

If all you want to do is sort the surfaces, you can get good results with fewer components by using the Sort Points component but you may need to round the values of the centroids.

Here is a test file showing what I’m trying to describe:

Sorting_Surfaces_221116.gh (31.0 KB)

The result in the middle is not sorted the way we want, but it is actually sorted correctly by numeric values.

Using this method, you can sort by y-x values instead of x-y values if desired:

sort by y-x.gh (15.1 KB)

If you want to group your data, the method shown by @parametriccuriosity works good but I would recommend rounding the data you’re using for the grouping and sorting criteria to avoid unexpected results.

Note that this is only rounding the data values that are being used for sorting or grouping criteria, the actual geometry is not being modified.