PointClosestObject

Finds the object that is closest to a test point.

Syntax

rhinoscriptsyntax.PointClosestObject(point, object_ids)

rhinoscript.pointvector.PointClosestObject(point, object_ids)

Parameters

point

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

object_ids

Required.  String, Guid, or list of Strings or Guids.  The identifiers of one or more point, point cloud, curve, surface, polysurface, or mesh objects to test against.

Returns

Tuple

A tuple of two values containing the results of the closest point calculation if successful.  The elements are as follows:

Element

Type

Description

0

Guid

The identifier of the closest object.

1

Point3d

The 3-D point that is closest to the closest object.

None

If not successful, or on error.

Example

import rhinoscriptsyntax as rs

objs = rs.GetObjects("Select target objects for closest point", 63)

if objs:

    point = rs.GetPoint("Test point")

    if point:

        results = rs.PointClosestObject(point, objs)

        if results:

              print "Object id:", results[0]

              rs.AddPoint( results[1] )

Also See

CurveClosestObject