Points to nearest points


I want to count the number of points that locate in nearest points.
Or I want to send the dots to nearest rectangle. How can I do?

@hojukys ,

can you explan what you exactly want? the perimeterpoints ?
https://dictionary.dynamobim.com/#/Geometry/Geometry/Action/ClosestPointTo


I’d like to make a list of many of the points that I’m currently drawing by connecting them to the nearest rectangle among the nine squares in red, or I’d like to count the number of points that are close to the rectangle. This is to think of each point as a unit load, a rectangle as a column, and then send the points to the column to calculate the fixed load.

First thing would be to isolate the nine squares if you haven’t already. Then you can just do a check for DistanceTo between every square and every dot. Use list levels so that the outcome is structured as a sublist for each dot, with distances to every square. That will allow you to use SortByKey to sort the squares by distance.

2 Likes

Hello,
Possible but I think longer than Mr. Nick’s proposal
1/create boundingbox from the 9 elements with distances separating the elements (or min max of the dot matrix)
2/ create a boundingbox enclosing the dot matrix
3/Intersection of the boudingboxes
4/Then Coutains

Cordially
christian.stan

What? :wink: @christian.stan ,

i can create the rectangles and the boundingBoxes… creating the bounding box does not work


Hello, here is the beginning of the reasoning for a column. :wink:


edit:
1st codeblock

a=1..20.2..0.4;
b=-2..11.8..0.4;

c=Point.ByCoordinates(a<1>,b<2>);

d=Point.X(c);
e=Point.Y(c);

CBG=Point.ByCoordinates(List.FirstItem(List.MinimumItem(d)),
List.FirstItem(List.MinimumItem(e)));

CHD=Point.ByCoordinates(List.LastItem(List.MaximumItem(d)),
List.LastItem(List.MaximumItem(e)));

f=BoundingBox.ByCorners(CBG,CHD);
BoundingBox.Contains(f,c);

2nd codeblock

a=[0,6,22];
b=[-5,5,8];

c=Point.ByCoordinates(a<1>,b<2>);

//Rectangle for column 1

CBG=Point.ByCoordinates(List.MinimumItem(a),
List.MinimumItem(b));

CHD=Point.ByCoordinates((a[1]-a[0])*0.5+a[0],
(b[1]-b[0])*0.5+b[0]);

f=BoundingBox.ByCorners(CBG,CHD);

Cordially
christian.stan

1 Like


What function I have to use…?
The number of level2 is 9
and each level3 is 735.
So, I have to find the minimum distances with 735dots and 9rectangles.

I would use SortByKey to sort your points by distance (key). I believe you’d want list levels @L2 for both inputs so that the sublists get sorted individually.

Note: I think you have your list structure inverted though. Your sublists should be 9 items long (representing the 9 rectangles) so that those are the items that get sorted by distance. That way when you take the first item in each sublist it will be the closest rectangle.

1 Like

So you want to know for a bunch of points (Gray points) which rectangle point (Black points) is closest?

Start

Something like this?

Result

I assume you already have the rectangle points (Black points) and the Evaluator points (Gray points)

3 Likes



@Joelmick ,

i have a sorting issue and scale problems, finally it colors just 3 lines and i can´t see them :slight_smile:
2022-07-07_17h14_52
2022-07-07_17h14_59

1 Like

Wow thank you!!!

1 Like

“Unable to create line. Points are likely coincident”

  • This means the 2 points between which you want to create a line are on top of each other.
    This happends if one of the eveluator points is on top of a rectangle point.

“Geometry Scaling”

  • Is what is says, a warning. you can always ignore that since it still computes right. the Dynamo team should get rid of this error since it is a complete hoax.

“Colors only 3 lines”

  • I think you need to provide more colors. If you have 9 rectangles → 9 Groups of curves → 9 colors

I have attached my graph below. You can just run in in the Dynamo Sandbox

Points to nearest points.dyn (67.1 KB)

1 Like