# Grouping Points Based on Proximity on a Surface in Grasshopper

hello

I have two sets of points, each containing 6 points. I want to group these points so that I can arrange them in clockwise or anticlockwise order for labeling.

my questions are

1. How to group the points on the surface based on their proximity.
2. How to determine the clockwise or anticlockwise order of the points in each group.
3. how to Output the groups of points in a way that can be easily used for labeling.

grouping the points.3dm (77.8 KB)
points group doubt.gh (18.3 KB)

Any guidance or insights from the experienced users would be greatly appreciated.

1. â€śGroupâ€ť (in fact : Clustering). One way is the standard one: K-Means (Google that) as far as you know the N of Clusters. Thereâ€™s also various other ways: for instance a more â€śgenericâ€ť distances Clustering as far as you know the max prox distance.
2. After defining a suitablle Coordinate System (say: a fitted Plane moved to the Cluster centdroid) AND â€śorientingâ€ť properly the Plane â€¦ one way is to order pts by Angle (of 2 Vectors: Plane XAxis and pt - Plane.Origin).
3. Use some higher order data collection Type like a DataTree.

For the 2 see the 3 indicative snaps attached to my answer to this (for â€śorientingâ€ť Planes Dot/Cross (Google these) Products are used) :

I think thereâ€™s a component for pulling points to the nearest shape, and it should output the index of the shape which was nearest. So thatâ€™s either going to be a 0 or a 1 if you use two curves. You can then use that number to sift your points into two outputs.

I canâ€™t check to make sure as my current build of Rhino crashes on startup. Itâ€™ll take a few hours to sort out.

The points are already separated into two groups; you just need to sort them.

points group doubt.gh (20.1 KB)

1 Like

Thank you, Seghier Khaled, for your insightful response. I have two additional questions regarding the grouping and arranging of points on a surface for labeling in Grasshopper

1. What if I have a large number of main pieces, such as x1, x2, â€¦, x30? How should I efficiently create the corresponding points for each main piece?

Question 2:

"2. What if I have an uneven distribution of points, with 14 points in x1 and only 10 points in x2? How should I handle this situation while maintaining the desired grouping and ordering?

Can you share an example?
Another situation may require a different solution.

"I apologize for not providing a detailed example in my previous message. My primary concern is how to establish a consistent starting point for labeling each group of points, ensuring that the labeling follows a clockwise or anticlockwise direction. For instance, I want to ensure that the labeling for group x1 starts at point 1 and proceeds in a clockwise manner, and similarly for the remaining groups.

Secondly, Iâ€™m wondering if thereâ€™s a more efficient approach to automating the creation of text components for each group of points. Currently, Iâ€™m manually creating text components for every group, which becomes tedious as the number of groups increases. Is there a way to automate this process using Grasshopperâ€™s native components or third-party add-ons?"

points group doubt (1).gh (39.5 KB)
grouping the points.3dm (148.2 KB)

Thank you

I made some changes to your script to ensure that all points are sorted. You can use the shift list and flip curve if you want to change the position of the letters or the direction.

points group doubt_2.gh (23.6 KB)

1 Like

â€śIâ€™m so thankful for your brilliant advice and the helpful solutions youâ€™ve shared so far. I tried my best to follow your instructions and apply the suggested methods, but Iâ€™ve faced a few hiccups along the way. I apologize for my persistent requests, but Iâ€™m eager to overcome these challenges and achieve the desired results. Your continued support and expertise would be immensely valuable to me.â€ť

"With your continued guidance, Iâ€™m confident that I can overcome the remaining hurdles and achieve the desired outcome. Would you please kindly assist me in addressing my remaining questions

Question 1:

Iâ€™m interested in establishing a reference point, or origin point, for each piece, consistently positioning it either on the left or right side. It indicates where to begin the assembly process.

Question 2:

I want to create labels for each piece and its sub-pieces. Each piece should have two labels: one in the center of the whole piece and another in the center of each sub-piece. The label should also show the pieceâ€™s position in the sequence, like â€śX1â€ť for the first whole piece and its sub-pieces.

Question 3:

In situations where a main piece, such as â€śX1,â€ť splits into two separate main pieces, one on the left and one on the right, Iâ€™d like to differentiate them by labeling the left piece â€śX1-LAâ€ť and the right piece â€śX1-RA.â€ť This approach would be consistently applied to all pieces, regardless of their position, ensuring clarity and organization.

If the generated label extends beyond the boundaries of a piece, could it be automatically resized to fit within the piece? This would prevent label overlap and ensure that the labels remain visible and unobtrusive.

points group doubt.gh (12.3 KB)
grouping the points.3dm (323.0 KB)

Dear Forum Members,

I hope this message finds you well.

Iâ€™m writing to follow up on my previous post regarding this problem.

Iâ€™m still facing difficulties with [problem description], and any insights or assistance you can provide would be greatly appreciated.

If you have any suggestions or recommendations, please let me know.

Thank you for your time and consideration.