Option Explicit
‘Script written by <Dave Kwon>
‘Script copyrighted by <Dave KWon>
‘Script version Sunday, October 18, 2009 9:00:53 PM
Call Main()
Sub Main()
Dim i,j,k, acs, aCenters, atan, aplan, sC, aps, aSeeds, aIndex
acs = rhino.GetObjects(“pick paths”, 4)
aSeeds = rhino.GetPointCoordinates(“pick pts”)
Dim drad : drad = 10
Call rhino.EnableRedraw(False)
For i = 0 To UBound(acs)-1
aCenters = rhino.DivideCurve(acs(i), 100)
For j = 0 To UBound(aCenters)
atan = rhino.CurveTangent(acs(i),rhino.CurveClosestPoint(acs(i), aCenters(j)))
aplan = rhino.PlaneFromNormal(aCenters(j), atan)
sc = rhino.AddCircle(aplan, drad)
aps = rhino.DivideCurve(sC, 20)
For k = 0 To Ubound(aps)
aIndex = SortBasedDist (aps(k),aSeeds)
Dim n, dd, pt, m
m = 0
ReDim aptsCrv(1)
For n = i+1 To UBound(aSeeds)-1
pt = rhino.EvaluateCurve(acs(i),rhino.CurveClosestPoint(acs(i),aSeeds(aIndex(n))))
dd = rhino.Distance(aSeeds(aIndex(n)), aps(k))
If dd > drad Then
aptsCrv(m) = aSeeds(aIndex(n))
If m = 1 Then Exit For
m = m + 1
End If
Next
‘-Call rhino.addCurve(array(aptsCrv(0), aps(k), aptsCrv(1)))
Call rhino.addCurve(array(aSeeds(aIndex(0)), aps(k), aSeeds(aIndex(1))))
Next
rhino.DeleteObject sc
Next
Next
Call rhino.EnableRedraw(True)
End Sub
Function SortBasedDist (pt,arpts)
Dim i
Dim dists()
ReDim dists (Ubound (arpts))
Dim sortedDist,j
Dim SortedIndex()
ReDim SortedIndex (Ubound (arpts))
For i=0 To ubound (arpts)
dists(i) = rhino.Distance (pt,arpts(i))
Next
sortedDist = rhino.SortNumbers (dists)
For i=0 To ubound(sortedDist)
For j=0 To ubound (dists)
If dists(j) = sortedDist(i) Then
SortedIndex(i) = j
End If
Next
Next
SortBasedDist = SortedIndex
End Function