Sorts an array of 3-D point based on the distance from a reference point. Points will be sorted from closest to farthest from the reference point.
Rhino.SortPointsByDistance (arrPoints, arrRefPt [, blnReturnPoints])
arrPoints |
Required. Array. An array of 3-D points. |
arrRefPt |
Required. Array. The reference point. |
blnReturnPoints |
Optional. Boolean. If True (Default), then an array of 3-D points, sorted by distance, is return. If False, then an array of indices that identify the sort order of arrPoints is returned. |
Array |
An array of 3-D points, sorted by distance, if successful. |
Null |
If not successful, or on error. |
Sub Test1()
Dim arrPoints, arrRefpt, arrPt
arrPoints = Rhino.GetPoints(,,"First point", "Next point")
If IsArray(arrPoints) Then
arrRefPt = Rhino.GetPoint("Reference point")
If IsArray(arrRefPt) Then
arrPoints = Rhino.SortPointsByDistance(arrPoints, arrRefPt, True)
For Each arrPt In arrPoints
Call Rhino.Print(Rhino.Pt2Str(arrPt))
Next
End If
End If
End Sub
Sub Test2()
Dim arrPoints, arrRefpt, arrSort, nIndex
arrPoints = Rhino.GetPoints(,,"First point", "Next point")
If IsArray(arrPoints) Then
arrRefPt = Rhino.GetPoint("Reference point")
If IsArray(arrRefPt) Then
arrSort = Rhino.SortPointsByDistance(arrPoints, arrRefPt, False)
For Each nIndex In arrSort
Call Rhino.Print(Rhino.Pt2Str(arrPoints(nIndex)))
Next
End If
End If
End Sub