Relative coordinates of Points in Dynamo

Hello. I’m trying to find a better way how to sort 4 points sets for paneling with Dynamo (adaptive families). Do you have any ideas how I can get relative coordinates of already existing points?
How can I get here the coordinates of the point from, lets say, new origin? Eventually It must work with thousands of points sets where each will get it’s new origin…

This post might be helpful.

If you create your points from different coordinate systems you should be able to get their relative coordinates. I’m wondering if this is even necessary if you keep your panel points in sublists though.

Its necessary because I’m working with surfaces that were created in other software like Rhino, AutoCAD etc.
And Vertices Points of surfaces sorted in random orders in sub lists. So for paneling with adaptive families its crucial to have all of them in the right order.

I didn’t create anything from different coordinate systems. I just import geometry, regenerate it in dynamo…

But if your vertices are in sublists you should be able to keep them in sublists. I think there’s a node to order points clockwise or something similar. I believe if you patch the points into a polygon then get the vertices again in Dynamo they should be returned in order.

Would converting the points to UVs be easier?

I will check this concept

This is what I usually get for UV points when I start with external geometryUntitled

I think I should create a topic for developers where this Dynamo issuer will be fully explained

I thought you already had the points and surfaces, so you would be able to do Surface.UVAtPoints, which would allow for faster computing. Would love to see the write up in question though.

Assuming you want to sequence points such that they create a non-intersecting boundary, see if this works for you…


boundaryCurve.dyn (14.2 KB)

def seq(pt:var[])
{
	ct = Point.ByCoordinates(Math.Sum(pt.X)/List.Count(pt),Math.Sum(pt.Y)/List.Count(pt));
	qa = Math.Round(Vector.ByTwoPoints(ct,pt).Normalized().AngleAboutAxis(Vector.YAxis(),Vector.ZAxis()));
	q1 = List.GroupByKey(List.SortByKey(pt,qa)["sorted list"],List.SortByKey(pt,qa)["sorted keys"])["groups"];
	q2 = List.Flatten(List.SortByKey(q1<1>,(Point.ByCoordinates(q1.X,q1.Y).DistanceTo(ct))<1>)["sorted list"],-1);
	return = q2;
};
pt1 = seq(pts);
7 Likes

Hello Mr.Vikram
Thank you so much for this logic with vector angle. I have learned a new way of data arrangement. I have studied your script very thoughtful and I would like to ask about q1 and q2.
Actually it works already at q1 with out List.GroupByKey node that you assigned at the very beginning of its row.
So starting from the List.GroupByKey node and all q2 is designed for cases where we have a lot of points close to each other in another words its an insurance for all possible cases. Am I right ?


here I Just put your script in more readable form

1 Like

Yes, I suppose :slight_smile:
Helps ensure it works even with numerous points …

3 Likes

this was a huge help for a problem I had Vikram, thanks

1 Like

Hi @Vikram_Subbaiah I am getting this error

can you please tell me why ?

List seems to have a conflict with other installed packages.
Prefix List with DSCore. (or use the code below, if you’re using a more recent Dynamo version)

def seq(pt:var[])
{
	ct = Point.ByCoordinates(Math.Sum(pt.X)/DSCore.List.Count(pt),Math.Sum(pt.Y)/DSCore.List.Count(pt));
	qa = Math.Round(Vector.ByTwoPoints(ct,pt).Normalized().AngleAboutAxis(Vector.YAxis(),Vector.ZAxis()));
	q1 = DSCore.List.GroupByKey(List.SortByKey(pt,qa)["sortedList"],DSCore.List.SortByKey(pt,qa)["sortedKeys"])["groups"];
	q2 = DSCore.List.Flatten(DSCore.List.SortByKey(q1<1>,(Point.ByCoordinates(q1.X,q1.Y).DistanceTo(ct))<1>)["sortedList"],-1);
	return q2;
};
pt1 = seq(pts);
3 Likes

Got it @Vikram_Subbaiah Thank you so much

1 Like