PointArrayClosestPoint

Finds the point in a list of 3-D points that is closest to a test point.

Syntax

rhinoscriptsyntax.PointArrayClosestPoint (points, test_point)

rhinoscript.pointvector.PointArrayClosestPoint (points, test_point)

Parameters

points

Required.  List.  A list of 3-D points to test.

test_point

Required.  List of three numbers, or Point3d.  The 3-D test point.

Returns

Number

The index of the element in the point list that is closest to the test point if successful.

None

If not successful, or on error.

Example

import rhinoscriptsyntax as rs

cloud = rs.GetObject("Select point cloud")

if cloud:

    point = rs.GetPoint("Point to test")

    if point:

        cloud = rs.PointCloudPoints(cloud)

        index = rs.PointArrayClosestPoint(cloud, point)

        if index is not None:

            point_id = rs.AddPoint(cloud[index])

            rs.SelectObject( point_id )

Also See

CurveClosestPoint

SurfaceClosestPoint