Hello

I have a mesh and a point outside of it. I am trying to find the closest point on the mesh, which in my case happens to be exactly one of the mesh vertices. I am then trying to find the edges and faces that are connected to this vertex.

Mesh.ClosestMeshPoint() gives me the closest location, but it does not give me the index of the vertex if ComponentIndexType==12, it only gives them for edges or faces. Is this correct? Therefore, I need to find the index of the vertex in the mesh, so that I can then find the connected edges and faces through the topology.

The below code in python works (if the closest point is on a vertex), but I would expect there to be a cleaner version that can do without creating a new list from mesh.TopologyVertices. Please let me know if you can think of a better way to do this. Thank you!

import rhinoscriptsyntax as rs

import Rhino

mesh = rs.coercemesh(rs.GetObject(‘mesh’))

p = rs.GetPointCoordinates(‘point’)[0]

meshPoint = mesh.ClosestMeshPoint(p,0.0)

vertices = [v for v in mesh.TopologyVertices]

index = vertices.index(Rhino.Geometry.Point3f(meshPoint.Point.X,meshPoint.Point.Y,meshPoint.Point.Z))

print index

print mesh.TopologyVertices.ConnectedEdges(index)

print mesh.TopologyVertices.ConnectedFaces(index)