Riorganizzare items di una lista

Salve,
vi espongo il risultato che devo ottenere:
Ho una serie di piatti ottogonali composto da due curve separate (curva rossa e curva nera che si sovrappongono), come in foto:


a me serve ottenere le coordinate dei 4 punti in asse al piatto ottogonale.

Con GH mi sono importato le due geometrie, da esse ho estrapolato i vertici e da questi vertici selezionerò solo quelli che formano il perimetro.
Ho trovato il centroide di ogni piatto. e come vedete nell’immagine seguente, spesso i due centroidi dei piatti corrispondono ma a volte no.

la mia intenzione era quella di creare una lista contenente i vertici di ogni coppia di piatti, andare a ridefinire il perimetro e quindi trovare i punti medi da cui cercherò le coordinate.

il problema è che avendo questa NON corrispondenza tra le coppie di piatti adiacenti, trovo delle linee che uniscono vertici di coppie diverse.

vorrei capire come riorganizzare le liste in maniera tale da ottenere gruppi di 8 vertici più prossimi per cercare il punto medio.
oppure se proprio concettualmente sto sbagliando e dovrei adottare un altra strategia.

Questo è quanto ottengo, per due punti riesco a recuperare le coordinate, mi mancano gli altri due.

Grazie

Hello Mateo, English list here. But Google helped:
_______
I’ll show you the result I need to obtain:
I have a series of octagonal plates composed of two separate curves (the red curve and the black curve overlapping), as shown in the photo:

I need to get the coordinates of the four points along the axis of the octagonal plate.
Using GH, I imported the two geometries, extracted the vertices from them, and from these vertices, I will select only those that form the perimeter.
I found the centroid of each plate, and as you can see in the following image, the two centroids of the plates often match, but sometimes they don’t.

My intention was to create a list containing the vertices of each pair of plates, redefine the perimeter, and then find the midpoints from which I will look for the coordinates.

The problem is that, given this non-correspondence between pairs of adjacent plates, I find lines joining vertices of different pairs.

I’d like to understand how to rearrange the lists to obtain groups of 8 closest vertices to find the midpoint.
Or, perhaps I’m just conceptually wrong and should adopt another strategy.

This is what I get. I can find the coordinates for two points, but I’m missing the other two.
--------

Please help us, to help you.
Internalise the data into your .gh file and upload it here, so we can see what your steps were. Regards, Eef

welcome to the forum
the official language is english :slight_smile: meno spaghetti, più inglese :slight_smile:

I assume you are talking of regular octagons, and I assume each half shape is always cut in such a way 3 full octagon edges are always present

in that case I would take adavantage of the inscribed/circumscibed circles

however you cut the shape, if you follow the above assumptions you will end up with 3x equal length sides, a longer one, and maybe up to two shorter ones

this means you can sort edges by descending length, the first one will always be the line that cuts the shape, and the second, third, fourth will always be your good eges:

at that point you can join them and take the vertexes, or can leave them separate and take the middle points, and use those to create a Fit Circle, which will give you the center of the Octagon:

last step, align the Circle Plane to the middle point of the middle segments:

and orient those on planes rotated by Pi:


align_octagon_halves.gh (15.3 KB)

The thing is… once you have calculated the circumscribed circle, you can overimpose a brand new octagon there, with same Radius, and ignore your original shapes :slight_smile: so why bothering with the alignment thing? :smiley:

align_octagon_halves_why_bother.gh (15.1 KB)



align_octagon_halves_vr_01.gh (41.0 KB)

Questo non toglie nulla a ciò che ha detto Inno.

Good morning, and sorry for not writing in English.

Thanks, Inno! I managed to get almost what I wanted. I hadn’t thought about approaching it with a circle.
I have a few questions (After each question, I will attach an image to make everything clearer):

  1. I have about 50 elements, and I’d like to order the index of each midpoint of the various edges so that they all follow the same numbering from 0 to 7. This way, I can assign coordinates only to the 4 points I’m interested in. Is this possible?

  2. Is it possible to display the full coordinates?

  3. Is it possible to create a label directly from Grasshopper that is visible in Rhino and shows:


    in this format for each point?

  4. Could you explain the Join Curves component? It’s the first time I’m using it.

Thanks everyone!
Thanks also to Volker, I’ll check out your script as well.

I’ve partially solved point 3, although the result isn’t very clean aesthetically

You need to provide us with a .gh file or something.

Here’s the script. In the last white quadrant, I’m trying to reorganize the numbering of each plate so that it follows the entire left row first, and then the right group

script prova - analisi ottagoni.gh (27.3 KB)

Please internalise data first before uploading

okay, sorry

script prova - analisi ottagoni.gh (37.8 KB)

To get the same order:

  • sort the first list (centers) and use result to create curve (polyline)
  • sort along to sort the centers of second list
  • (i left a polyline through centers, so you see the order now)
  • use the same sorting order to sort both lists (curves).
    script prova - analisi ottagoni-EW.gh (32.4 KB)

Okay, thank you very much.
I have another request. Having 8 vertices numbered from 0 to 7, and for example 20 octagons that I can number from A to Z, I would like to visualize in Rhino a table that shows:

A.0 and the respective xyz coordinates
A.1 and the respective xyz coordinates

A.7 and the respective xyz coordinates

Then for the second geometry:
B.0 and the respective xyz coordinates

B.7 and the respective xyz coordinates

And so on for all the others.

Starting from this script, how can I achieve that?
I can easily display the coordinates with the “Deconstruct Point” component and then visualize them with “Text Tag.”

However, since I’m a beginner, I don’t quite understand how to manage the data structure in Grasshopper.
Because with the “Concatenate” component, I can combine A.0, A.1, etc., but how do I associate the xyz values to the correct point?

maybe this can help you


script prova - analisi ottagoni-EW2.gh (26.3 KB)

If you do a list item, or any work on the list with points.
Always do the same with the list of text-items.
So they will have the same order.

Regards, Eef

I’m sorry, but that’s not exactly what I want to achieve.
With a single point, I can manage it, but my problem is handling multiple points.
I’m attaching a diagram of what I want to achieve so I can explain myself better.

I need to obtain the coordinates of each vertex, but since there are 8 vertices for each curve, I don’t know how to associate the centroid letter with those vertices for each curve.
Additionally, the two groups of geometries should follow the same alphabetical sequence (diagram at the top left) to then obtain the coordinates for each point in a unique way (example table at the top right).

Therefore, I need to assign 3 values (x, y, z) to the 8 vertices (0, 1, … 7) for each geometry (A, B, C, D, …).

script ottagoni.gh (22.2 KB)

From the script I’m attaching, I think it’s necessary to merge the two lists obtained from the output of “Cull Index” and get a single list containing the 35 curves, each having 8 vertices.
So, I should end up with a group of 35 lists (the curves), each consisting of 8 indices (the vertices) whose items are the coordinates of each point. But I don’t know how to do it.

I hope I’ve explained myself clearly. Thanks, everyone.

If I understand correctly, you want to generate tabulated data like a spreadsheet? Grasshopper can’t really do this natively. You’ll need a plugin to write .csv or Excel files. I’ve used the TToolbox component “Write to Excel Classic” in the past.

This bit though:

is easy. Just merge your data before processing it. Not sure why there are two sets of curves to start with, mind you!

OK, let’ s do this step by step.
As a demo I do just one group first.

  1. Sort the polygons using the X of the centre point of the polygons
  2. Create a Char sequence with the same list length and sorting.

It is important to all actions same time on your list of polygons + list of chars, to not disturb the order. (using entwine + explode tree comes in very usefull there)
Advice: Use numbers untill the last stage, and then replace number by chars.
demo sort polygon + char_EW.gh (25.2 KB)


To get the sorting of the other group is a bit different.
You are a bit lucky, but seems the Y-order is just fine to do the same sorting for the other group


script ottagoni VR 1.gh (78.0 KB)

Because two different data sets?

Then last:

Get the index numbers of vertexpoint + x, y, z values
use index number to find char in list (I made manual list to skip some chars)

regards, Eef


demo sort polygon + char_EW2.gh (22.1 KB)

Or if you want them all in one list:

demo sort polygon + char_EW3.gh (16.3 KB)