(n)certainties/LAB M4

USC / 2010-2011

(n)certainties/LAB M4 header image 3

Curve release – to Song&Guo

Option Explicit
‘Script written by <Suqi>
‘Script copyrighted by <insert company name>
‘Script version Tuesday, 05 October 2010 18:43:32

Call Main()
Sub Main()
Dim arrcurves
arrcurves = rhino.getobjects(“pick all the curves”,4)

Dim arrpoints
ReDim arrpoints(ubound(arrcurves))
Dim iterations
iterations = rhino.getinteger(“how many steps”,10,3,50)
Dim i
Dim n
Call rhino.AddLayer(“straight line”,rgb(15,255,15))
Dim length
ReDim length(ubound(arrcurves))
For i = 0 To ubound(arrcurves)
length(i) = rhino.CurveLength(arrcurves(i))
Next
”Call rhino.EnableRedraw(True)
For n = 0 To iterations
Call rhino.EnableRedraw(True)

For i = 0 To ubound(arrcurves)
Call rhino.EnableRedraw(False)
Call rhino.enableobjectgrips(arrcurves(i))
arrpoints = Rhino.ObjectGripLocations (arrcurves(i))
Dim j
Dim closept,para,parastart,paraend,startpt,domain,propotion,refendpt,refline
Dim refpt
ReDim refpt(ubound(arrpoints))
Dim vector
ReDim vector(ubound(arrpoints))

Rhino.Print “Curve length: ” & CStr(length(i))
For j = 0 To ubound(arrpoints)
startpt = rhino.curvestartpoint(arrcurves(i))
domain = rhino.CurveDomain(arrcurves(i))
parastart = domain(0)
paraend = domain(1)
para = rhino.CurveClosestPoint(arrcurves(i),arrpoints(j))
closept = rhino.EvaluateCurve(arrcurves(i),para)
propotion = (para – parastart)/(paraend-parastart)

startpt = rhino.CurveStartPoint(arrcurves(i))
refpt(j) = rhino.PointAdd(startpt,array(0,0,propotion*length(i)))
vector(j) = rhino.Vectorcreate(refpt(j),arrpoints(j))
arrpoints(j) = rhino.PointAdd(arrpoints(j),rhino.VectorScale(vector(j),n/iterations))
If n = iterations And j = ubound(arrpoints) Then
refline = rhino.AddLine(startpt,rhino.PointAdd(startpt,array(0,0,length(i))))
Call rhino.ObjectLayer(refline,”straight line”)
End If
Next
Call Rhino.ObjectGripLocations (arrcurves(i),arrpoints)
Next
Next

End Sub