# How can I renumber curves? I want to renumber the curves according to Z-axis

Hi everyone,

I have a series curves, one up one according to Z-axis. However, the number of the curves is not continuous in Z-axis. How can I renumber the curves?

How I show curve number:

Thanks!
renumber.3dm (229.2 KB)

if youâre bringing the curves from rhino in the first place, why not simply select them âin orderâ (bottom to top or vice versa)?

I canât open your R6 file in R5. What it looks like is that you want to sort the curves in Z-order? There are several ways to do that, easier done than explained.

Thank you Joseph!
renumber_v5.3dm (239.4 KB) Here I uploaded the v5 file.

Hereâs the general idea using planar curves I created: (internalized)

sort_curves_2019Jul10a.gh (10.1 KB)

Your curves, however, look more complicatedâŚ not planar and not all starting at the same place, so that could mix things upâŚ standby.

OK, I divided each curve into ten points and used their Average (roughly center) for the sorting. The âTree/List Viewerâ is just a trace tool for examining trees of geometry in a visual way.

sort_curves_2019Jul10b.gh (126.5 KB)

All curves internalized, no need for Rhino file.

P.S. To explain further, Sort is sorting Z values and the Avr points (âAâ input) and curves (âBâ input) get sorted in the same sequence as the âKâ (Keys) input.

Thatâs a great job, Joseph!!
Thank you so much for your kind and prompt help!

Well, this isnât infallible. Irregular curves could mix it up, requiring more effort to determine valid Z values to sort by. But this is the general idea.

The more I use it, the more I like it. Thanks again!

They Loft better when sorted, eh? But I see two areas that look ugly (twisted), even with âAlign sectionsâ enabled. Still needs work?

To get a clean Loft, I added an Anemone loop (white group) after sorting them in sequence. It flips each curve and adjusts its Seam (start/end point) to match its predecessor. No Loft options required.

sort_curves_2019Jul10c.gh (131.8 KB)

P.S. This is what Loft produces at three stages of the model. Left to right, below:

1. raw curves, unsorted
2. curves sorted by Z value of Avr points
3. sorted curves after Anemone with matching directions and seams

2 Likes

WowâŚJoseph, your work is fantastic!! And thank you so much for your kindness! I really need some time to fully understand your code :).

1 Like

Hi Joseph,

Here is a new problem. As you see the pic, this kind of curves still has the problem of sorting. Coul you please help me have a look?

Thank you again!

curves.3dm (907.7 KB) sort_curves_problem0827.gh (28.4 KB) )

There is no magical best solution that leaps to mindâŚ Maybe sort the rings by the highest point on each ring? Seems to work, didnât check all possible cases.

sort_curves_problem_2019Aug28a.gh (28.8 KB)

1 Like

Hi Joseph, thank you so much!!
Actually I had the same idea (find the higest point) of youâŚ However, I canât realize it in GH :).
I think your method can be suitable for most my cases.
Nice job!