MeshClosestPoint

Returns the point on a mesh that is closest to a test point.

Syntax

rhinoscriptsyntax.MeshClosestPoint (object_id, point, maximum_distance=None)

rhinoscript.mesh.MeshClosestPoint (object_id, point, maximum_distance=None)

Parameters

object_id

Required.  String or Guid.  The identifier of a mesh object.

point

Required.  List of 3 numbers or Point3d.  A 3-D point to test.

maximum_distance

Optional.  Number.  Optional upper bound on the distance from the test point on the mesh. If you are only interested in finding a point Q on the mesh when point.DistanceTo(Q) < maximum_distance, then set maximum_distance to that value.

Returns

List

A list containing the results of the calculation, if successful. The array elements are as follows:

Element

Type

Description

0

Point3d

The 3-D point on the mesh object.

1

Number

The index of the mesh face on which the 3-D point lies.

None

If not successful, or on error.

Example

import rhinocriptsyntax as rs

obj = rs.GetObject("Select mesh", rs.filter.mesh)

point = rs.GetPoint("Pick test point")

intersect = rs.MeshClosestPoint(obj, point)

if intersect: rs.AddPoint(intersect)

Also See

MeshFaceCount

MeshFaces