Sort points

"Hello, I want to sort the points of this shape so they follow a clockwise order. When I rotate the shape in Rhino, the sorting should remain consistent regardless of the rotation. Can anyone help me? I already tried using ‘To Polar’ combined with the points of the shape and a plane constructed from its vectors, but for some points it didn’t work as expected, as you can see.

sort points for a form.3dm (43.6 KB)

flip curve

You can either flip the curves or reverse the points list

oké, what if the points and lines have a random order?

Point on joined and/or curves don’t have a random order. So joining curves is the first thing to try.

If you just have a list of points with no order, in some cases it is possible to fit a circle through the points and use the circle to sort the points.

Convex hull can also be used to create a first curve for sorting.

1 Like

And if i move the plane or rotate it, is the point order still the same for the point. It is not the intention that another point becomes zero

Use the Seam component to set the curve end point


I tried your method but it does not work as you see. Also the geometry is not created in rhino but in forma. so it is not consistent.

Do you know another way?

Please share a file

1 Like

Here’s a method to set the 0 point of each polyline to a corner nearest to a desired vector. Rotation of the resulting polylines will not change the vertex numbering. If different polylines require different target vectors at the input stage, you’ll need to make multiple copies of the MDslider and make sure they’re merged/duplicated in the same order as the input geometry.

ordered points.gh (12.4 KB)

This does appear to be the same project as your previous threads, so I’ll repeat myself too: Without knowing what the inputs and desired outputs are, it will be hard to help you. The fact that you are still trying to sort points on a polyline after two months says to me that there is probably a better way to achieve your desired results.

EDIT: You said clockwise, so we need to reverse the list and adjust the shift by 1.

ordered points CW.gh (12.7 KB)

1 Like

@Tom_Newsom wrote: "This does appear to be the same project as your previous threads, " That triggered me, and made me wondering what was happening. It seems:
@Nick31:

  • is working on a classified project (some building I guess).
  • while doing so he runs into issues, he cannot solve. Looking at those issues:
    – in earlier stages of the project movements, errors, etcetera were made, what gives problems in later stages.
    – Beste way (advice to @Nick31 a couple of times) is to go back to where the issue was caused and solve it at the root.
  • maybe this may or cannot be done, so the next best step is to solve the issue at the later stages, what gives great puzzles for grasshopper fanatics (there are many on the forum, so best place to go :slight_smile: (this is a compliment).

Because the material is classified, @Nick31 cannot share the files he is working on, so that is why he makes us work with images. To compensate he creates examples, what explain better what he is asking. Problem is, that these examples, just do not have the context from the real problem.

How to workaround this:
At @Nick31 : Please provide us with the “real stuff”. And I understand you cannot share your classified files. So the best would be to isolate the part with the problem and save this in a second file, to be shared with us. Without the real context, I think this will not break the classification. How to do this. Let me show this on an example what I worked on last weeks:

  • Imagine this is classified material, and I only want to ask something about the spot with the red line around. (see next image).

  • I could only send this image, but then it will be hard to understand what is happening there.

  • So to isolate this:

  1. Add NUM, GEO holders + internalise!! data what is needed.
  2. Then select all components you want to show to the forum.
  • create a new .gh file. Copy paste those components to the new file. (Shift + Command + V (in Mac)) . Connect the correct lines to the internalised data.

    Check if the result is OK to be shown on the forum. (In my example , you see the endresult, so probably I had be better to cripple this a bit before uploading. But because it is no classified I am OK)
  • send to forum
    TESTEXPORTEW.gh (10.6 KB)
    and ask your questions with trust.
    NB: Delete those temporarely NUM GEO holders in your original.

Maybe this procedure can help to get you better and faster answers. Regards, Eef

1 Like

Hello Eef,

Thankyou for undestanding my goals and your advice. I internalised the data before sorting the points for each surface.

The goal is that each surface has a consistent point ordening. If I rotate or move or mirror the surface, the point ordening must still be the same. So the number 0 must be at the same position. To achieve this I thought of making a plane for each surface. In the end I want to determain where I want my zero point for each surface but also for all surfaces.

All this means only for the big surfaces.

sort points test case.gh (101.8 KB)

Thank you. That is lot of lines :wink:
what grasshopper things did you already try, to get what you want. ?

I tried the following examples

  1. making a plane for each surface based on the vectors from each surface
  2. control polygon node. but it was not consistent for every surface
  3. clashing the smaller surfaces with the bigger ones. result short lines of both sides but that only worked for the 4 cornered squares. And if there is no surface there I can’t clash also.
  4. tried to sort the lines with help of the world xy plane for each surface.

Those things I tried.

What about the option 4: but working with the vectors.

  • Each vector has X, Y and Z value.
  • If you sort the vectors of a surface (I see there are 624 branches in your data. Every branch is a surface?).
  • Then you can choose the vector with lowest, X , Y and Z).
  • with area find the center of your surface
  • circle (with any radius) on the surface.
  • sort along curve.
  • polyline
  • bounded surface

I would only do this action at the end, when you need the numbers, Save a lot of calculation (time).

Regards, Eef

This is what I want. If the forms are rotated or get another position on the axis the numbers of the points are keeping the same position.

Could you give me an example?

Sorry,

Yes, every branch is a surface.