Hi @sara22.martin22,

Here’s a purely pythonic version, if you’re interested.

It uses the RTree algorithm to first find the closest mesh face centers for each curve division point. The shortest distance between these face centers and the individual curve division point is then evaluated. A line is drawn for the shortest distance only. However, other than in @seghierkhaled’s solution, only one closest line gets drawn, when multiple potential connections have the same distance, and thus no clear closest one is discernible.

This is what the script looks like:

```
import Rhino.Geometry as rg
import Grasshopper as gh
# Get the curve division points (including the end points)
crv_points = [Curve.PointAt(t) for t in Curve.DivideByCount(Count, True)]
# Get the mesh face centers
face_centers = [Mesh.Faces.GetFaceCenter(i) for i in xrange(Mesh.Faces.Count)]
# Initialise an RTree
rtree = rg.RTree()
# Populate the RTree with the mesh face centers and indices
for i, center_pt in enumerate(face_centers):
rtree.Insert(center_pt, i)
# Evaluate the closest lines from each curve point to a mesh face center
lines = []
for pt in crv_points:
# Find the closest mesh faces within the search radius
closest_faces = [] # indices of closest faces
search_sphere = rg.Sphere(pt, Radius)
rtree_callback = lambda sender, args: closest_faces.append(args.Id)
rtree.Search(search_sphere, rtree_callback)
# Find the closest line
if len(closest_faces) > 0:
dists = [pt.DistanceTo(face_centers[i]) for i in closest_faces]
sorted_faces = [f for _, f in sorted(zip(dists, closest_faces))]
closest_line = rg.Line(pt, face_centers[sorted_faces[0]])
lines.append(gh.Kernel.Types.GH_Line(closest_line))
# Outputs
a = lines
```

And here’s the GH file:

model_point_v3.gh (7.2 KB)