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

Rhino.BrepClosestPoint (strObject, arrPoint [, blnFaces])

Parameters

strObject

Required. String. The object's identifier.

arrPoint

Required.  Array.  The test, or sampling, point.

blnFaces

Optional.  Boolean.  If True, then the closest point calculations will be restricted to faces. Of omitted or False (Default), then all components will be used in the calculation.

Returns

Array

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

Element

Type

Description

0

Array (X, Y, Z)

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

1

Array (U, V)

Parameter values of closest point.  Note, V is 0 if the component index type is Brep edge or vertex.

2

Array (type, index)

The type and index of the Brep component that contains the closest point. Possible types are:

Types

Description

1

Brep vertex

2

Brep edge

3

Brep face

4

Brep trim

5

Brep loop

3

Array (X, Y, Z)

The normal to the Brep face, or the tangent to the Brep edge.  

Null

If not successful, or on error.

Example

Const rhObjectSurface = 8

Dim strObject, arrPoint, arrCP

strObject = Rhino.GetObject("Select a surface", rhObjectSurface)

If Rhino.IsSurface(strObject) Then

arrPoint = Rhino.GetPoint("Pick a test point")

if IsArray(arrPoint) Then

arrCP = Rhino.BrepClosestPoint(strObject, arrPoint)

If IsArray(arrCP) Then

Rhino.AddPoint arrPoint

Rhino.AddPoint arrCP(0)

End If

End If

End If

Also See

EvaluateSurface

IsSurface

SurfaceClosestPoint