How to link Mtext content with X & Y to a circle that is closer to it than the rest of the circles
Arrange in order of proximity
to form a point from (X & Y FROM a circle & Mtext content)
SORT_PONT&TEXT_TOCIVILPOINTS 01.dwg (917.5 KB)
SORT_PONT&TEXT_TOCIVILPOINTS.dyn (15.7 KB)
@hosneyalaa you can try with bellow process…
- Find X,Y postion of Mtext (use toolkit node objectextension.getparameter)
- create dynamo points from Mtext (x,y)
- create points at the center of circle.
- use node closestPointto to find the nearest points between the two geometry points.
you can give it a try.
I will try
You have reached this stage
I didn’t understand how LOOP works on all points
If you have enough time, help
SORT_PONT&TEXT_TOCIVILPOINTS 01.dyn (46.2 KB)
Apologies, i thinki i missed something the closest point wont work for all points.
The solution is from this link
With a little modification
# Load the Python Standard and DesignScript Libraries import sys import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * # Inputs short_list = IN long_list = IN # Output list result =  # Loop check for each point in the short list for s in short_list: # List for distances dist =  for l in long_list: # Distance to point s d = Geometry.DistanceTo(s,l) dist.append(d) # Lowest distance in list min_d = min(dist) # Index of lowest distance in list min_ind = dist.index(min_d) # Get the closest point from the long_list closest_p = long_list[min_ind] # Add the point to the results, as it is the closest to the point from the short list result.append(closest_p) # Output the results OUT = result
Thanks for sharing this.