CurveClosestObject

Returns the 3-D point locations on two objects where they are closest to each other.  Note, this function provides similar functionality to that of Rhino's ClosestPt command when used with the Object option.

Syntax

rhinoscriptsyntax.CurveClosestObject (curve_id, objects)

rhinoscript.curve.CurveClosestObject (curve_id, objects)

Parameters

curve_id

Required.  String or Guid.  The identifier of the curve object to test.

strObject

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

Returns

Tuple

A tuple of three elements 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.

2

Point3d

The 3-D point that is closest to the test curve.

None

If not successful, or on error.

Example

import rhinoscriptsyntax as rs

filter = rs.filter.curve | rs.filter.pointcloud | rs.filter.surface | rs.filter.polysurface

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

if objects:

    curve = rs.GetObject("Select curve")

    if curve:

        results = rs.CurveClosestObject(curve, objects)

        if results:

              print "Curve id:", results[0]

              rs.AddPoint( results[1] )

              rs.AddPoint( results[2] )

Also See

CurveClosestPoint

EvaluateCurve

IsCurve