BrepClosestPoint

Returns the point on a surface or polysurface that is closest to a test point. This function works on both untrimmed and trimmed surfaces.

Syntax

rhinoscriptsyntax.BrepClosestPoint (object_id, point)

rhinoscript.surface.BrepClosestPoint (object_id, point)

Parameters

object_id

Required. String or Guid. The object's identifier.

point

Required.  List of three numbers or Point3d.  The test, or sampling, point.

Returns

List

An array of closest point information if successful.  The list will contain the following information:

Element

Type

Description

0

Point3d

The 3-D point at the parameter value of the closest point.

1

List (U, V)

Parameter values of closest point.  Note, V is 0 if the component index type is brep_edge or brep_vertex.

2

List (type, index)

The type and index of the brep component that contains the closest point. Possible types are brep_face, brep_edge or brep_vertex.

3

Vector3d

The normal to the  brep_face, or the tangent to the brep_edge.  

None

If not successful, or on error.

Example

import rhinoscriptsyntax as rs

obj = rs.GetObject("Select a surface", rs.filter.surface)

if obj:

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

    if point:

        arrCP = rs.BrepClosestPoint(obj, point)

        if arrCP:

            rs.AddPoint(point)

       rs.AddPoint( arrCP[0] )

Also See

EvaluateSurface

IsSurface

SurfaceClosestPoint