(n)certainties – USC – Fall 2009

(n)certainties – USC – Fall 2009 header image 3

PROTOCOLS

DAVE SAUNDERS_script

Option Explicit

Call kochCurveMaker()

Sub kochCurveMaker()

Dim crvs, minLen, scl

Dim crv

Dim deg

crvs=rhino.getObjects(“pick seed lines(1D)”,4)

If isnull(crvs) Then Exit Sub

minLen=rhino.GetReal(“enter minimum length”,20)

If isnull (minLen) Then Exit Sub

scl=rhino.getReal(“enter scaling factor”,1)

If isnull(scl) Then Exit Sub

rhino.enableredraw False

For Each crv In crvs

‘check degree

deg=rhino.curveDegree(crv)

If deg>1 Then

rhino.messageBox “curve is not 1D..exiting”

Exit Sub

End If

‘divide curve

divideCurve crv,minLen,scl

Next

rhino.enableredraw True

Rhino.Print(“OPERATION COMPLETE”)

End Sub

Function divideCurve(crv,minLen,scl)

” option random

’scl = scl * rnd

‘check length

Dim len:len=rhino.curveLength(crv)

MARCUS XIAOQIN & CHUCK XIA_script

Option Explicit
‘Script written by <insert name>
‘Script copyrighted by <insert company name>
‘Script version Friday, November 13, 2009 10:55:04 PM
Call Main()
Sub Main()
Dim strCurveID, t, arrPt, arrPts(),t1
strCurveID = Rhino.GetObject(“Select a curve to sample”, 4, True, True)
If IsNull(strCurveID) Then Exit Sub
‘Call Rhino.EnableRedraw(False)
Dim count,transPt, transPtOld, transPtNew, interLine, arrParameter
Dim midPt, newCrv
Dim curveLengthSample
curveLengthSample = rhino.CurveLength(strCurveID)
rhino.print curveLengthSample
count = 0
For t = 0.01 To 1 Step 0.02
ReDim Preserve arrPts(count)
If count > 0 Then
transPtOld = transPt ‘TRANS2
End If
arrParameter = AddPointAtR1Parameter(strCurveID, t)
arrPts(count) = arrParameter(0)
transPt = arrParameter(2)’TRANS1
transPtNew = arrParameter(1)
‘rhino.Addpoint transPt
If count > 0 Then
interLine = rhino.AddLine(transPtOld, transPtNew)
midPt = rMidPrepPt(interLine)
newCrv = rhino.AddCurve(array(transPtOld,midPt,transPtNew))
rhino.DeleteObject interLine
End If
count = count + 1
Next
‘Call Rhino.EnableRedraw(True)
End Sub
Function AddPointAtR1Parameter(strCurveID, dblUnitParameter)
AddPointAtR1Parameter = Null
Dim crvDomain, dblR1Param, arrR3Point, strPointID
crvDomain = Rhino.CurveDomain(strCurveID)
dblR1Param = crvDomain(0) + dblUnitParameter * (crvDomain(1) – crvDomain(0))
arrR3Point = Rhino.EvaluateCurve(strCurveID, dblR1Param)
strPointID = Rhino.AddPoint(arrR3Point)
‘AddPointAtR1Parameter = strPointID
Dim tangentVec, prepVec,reversePrepVec
tangentVec = Rhino.CurveCurvature(strCurveID, dblUnitParameters)(1)
prepVec = rhino.VectorRotate(tangentVec,-90,array(0,0,1))
prepVec = rhino.VectorUnitize(prepVec)
prepVec = rhino.VectorScale(prepVec,3.2+rnd*0.4)
reversePrepVec = rhino.VectorReverse(prepVec)
Dim pt1, pt2
pt1 = rhino.PointAdd(arrR3Point, prepVec)
pt2 = rhino.PointAdd(arrR3Point, reversePrepVec)
‘pt1 = rhino.AddPoint(pt1)
‘pt2 = rhino.AddPoint(pt2)
Dim crv, midPt,newCrv
crv = rhino.AddLine(pt1,pt2)
midPt = midPrepPt(crv)
newCrv = rhino.AddCurve(array(pt1,midPt,pt2))
rhino.DeleteObject crv
AddPointAtR1Parameter = array(strPointID,pt1,pt2)
End Function
Function midPrepPt(line)
Dim startPt, endPt, midPt
startPt = Rhino.CurveStartPoint(line)
endPt = Rhino.CurveEndPoint(line)
midPt = Rhino.CurveMidPoint(line)
Dim vec
vec = rhino.VectorCreate(endPt,startPt)
vec = rhino.VectorRotate(vec,90,array(0,0,1))  ”rotate nishizhen
vec = rhino.VectorUnitize(vec)
vec = rhino.VectorScale(vec,1000)
Dim addMidPt
addMidPt = rhino.PointAdd(midPt,vec)
midPrepPt = addMidPt
‘rhino.AddPoint addMidPt
End Function
Function rMidPrepPt(line)
Dim startPt, endPt, midPt
startPt = Rhino.CurveStartPoint(line)
endPt = Rhino.CurveEndPoint(line)
midPt = Rhino.CurveMidPoint(line)
Dim vec
vec = rhino.VectorCreate(endPt,startPt)
vec = rhino.VectorRotate(vec,-90,array(0,0,1))  ”rotate nishizhen
vec = rhino.VectorUnitize(vec)
vec = rhino.VectorScale(vec,1000)
Dim addMidPt
addMidPt = rhino.PointAdd(midPt,vec)
rMidPrepPt = addMidPt
‘rhino.AddPoint addMidPt
End Function
Function avoid (obstacle,threshold)
End Function

Option Explicit’Script written by <insert name>’Script copyrighted by <insert company name>’Script version Friday, November 13, 2009 10:55:04 PM
Call Main()Sub Main() Dim strCurveID, t, arrPt, arrPts(),t1 strCurveID = Rhino.GetObject(“Select a curve to sample”, 4, True, True) If IsNull(strCurveID) Then Exit Sub ‘Call Rhino.EnableRedraw(False) Dim count,transPt, transPtOld, transPtNew, interLine, arrParameter Dim midPt, newCrv Dim curveLengthSample curveLengthSample = rhino.CurveLength(strCurveID) rhino.print curveLengthSample count = 0 For t = 0.01 To 1 Step 0.02 ReDim Preserve arrPts(count) If count > 0 Then transPtOld = transPt ‘TRANS2 End If
arrParameter = AddPointAtR1Parameter(strCurveID, t) arrPts(count) = arrParameter(0) transPt = arrParameter(2)’TRANS1 transPtNew = arrParameter(1) ‘rhino.Addpoint transPt
If count > 0 Then interLine = rhino.AddLine(transPtOld, transPtNew) midPt = rMidPrepPt(interLine) newCrv = rhino.AddCurve(array(transPtOld,midPt,transPtNew)) rhino.DeleteObject interLine End If count = count + 1 Next ‘Call Rhino.EnableRedraw(True)End Sub
Function AddPointAtR1Parameter(strCurveID, dblUnitParameter) AddPointAtR1Parameter = Null Dim crvDomain, dblR1Param, arrR3Point, strPointID crvDomain = Rhino.CurveDomain(strCurveID)
dblR1Param = crvDomain(0) + dblUnitParameter * (crvDomain(1) – crvDomain(0)) arrR3Point = Rhino.EvaluateCurve(strCurveID, dblR1Param) strPointID = Rhino.AddPoint(arrR3Point) ‘AddPointAtR1Parameter = strPointID Dim tangentVec, prepVec,reversePrepVec tangentVec = Rhino.CurveCurvature(strCurveID, dblUnitParameters)(1) prepVec = rhino.VectorRotate(tangentVec,-90,array(0,0,1)) prepVec = rhino.VectorUnitize(prepVec) prepVec = rhino.VectorScale(prepVec,3.2+rnd*0.4) reversePrepVec = rhino.VectorReverse(prepVec) Dim pt1, pt2 pt1 = rhino.PointAdd(arrR3Point, prepVec) pt2 = rhino.PointAdd(arrR3Point, reversePrepVec) ‘pt1 = rhino.AddPoint(pt1) ‘pt2 = rhino.AddPoint(pt2) Dim crv, midPt,newCrv crv = rhino.AddLine(pt1,pt2) midPt = midPrepPt(crv) newCrv = rhino.AddCurve(array(pt1,midPt,pt2)) rhino.DeleteObject crv AddPointAtR1Parameter = array(strPointID,pt1,pt2) End Function
Function midPrepPt(line) Dim startPt, endPt, midPt startPt = Rhino.CurveStartPoint(line) endPt = Rhino.CurveEndPoint(line) midPt = Rhino.CurveMidPoint(line)
Dim vec vec = rhino.VectorCreate(endPt,startPt) vec = rhino.VectorRotate(vec,90,array(0,0,1))  ”rotate nishizhen vec = rhino.VectorUnitize(vec) vec = rhino.VectorScale(vec,1000) Dim addMidPt addMidPt = rhino.PointAdd(midPt,vec) midPrepPt = addMidPt ‘rhino.AddPoint addMidPt End Function
Function rMidPrepPt(line) Dim startPt, endPt, midPt startPt = Rhino.CurveStartPoint(line) endPt = Rhino.CurveEndPoint(line) midPt = Rhino.CurveMidPoint(line)
Dim vec vec = rhino.VectorCreate(endPt,startPt) vec = rhino.VectorRotate(vec,-90,array(0,0,1))  ”rotate nishizhen vec = rhino.VectorUnitize(vec) vec = rhino.VectorScale(vec,1000) Dim addMidPt addMidPt = rhino.PointAdd(midPt,vec) rMidPrepPt = addMidPt ‘rhino.AddPoint addMidPt End Function
Function avoid (obstacle,threshold)
End Function

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version Wednesday, November 25, 2009 4:40:35 PM

Call Main()

Sub Main()

Dim arrObj

arrObj = rhino.GetObjects(“get all the lines”,4)

Dim i, crvLength, crvPts

Dim tangentVec1, tangentVec2, tangentVec3

Dim ptA, ptB, ptC

Dim substance

rhino.EnableRedraw False

For i = 0 To Ubound(arrObj)

crvLength = rhino.CurveLength(arrObj(i))

crvPts = rhino.DivideCurve(arrObj(i),2) ‘crvPts(0),crvPts(1),crvPts(2)

tangentVec1 = rhino.CurveTangent(arrObj(i),0)

tangentVec2 = rhino.CurveTangent(arrObj(i),0.5)

tangentVec3 = rhino.CurveTangent(arrObj(i),1)

ptA = rhino.CurveStartPoint(arrObj(i))

ptB = rhino.CurveMidPoint(arrObj(i))

ptC = rhino.CurveEndPoint(arrObj(i))

substance = hole (ptA, ptB, ptC, crvLength, tangentVec1,tangentVec2,tangentVec3)

Next

rhino.EnableRedraw True

End Sub

Function hole (ptA, ptB, ptC, crvLength, tangentVec1,tangentVec2,tangentVec3)

‘arrPt = rhino.PointCoordinates(arrPt)

Dim vec1, vec2,vec3

Dim vecMid1, vecMid2, vecStart1, vecStart2, vecStart3, vecStart4, vecEnd1, vecEnd2, vecEnd3, vecEnd4

Dim pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10

Dim crv, srf

vec1 = rhino.VectorUnitize(tangentVec1)

vec1 = rhino.VectorScale(vec1,crvLength/10)

vec1 = rhino.VectorRotate(vec1,180,array(0,0,1))

vecStart1 = rhino.VectorRotate(vec1,-60-rnd*10,array(0,0,1))

vecStart2 = rhino.VectorRotate(vec1,-50+rnd*10,array(0,0,1))

vecStart3 = rhino.VectorRotate(vec1,50-rnd*10,array(0,0,1))

vecStart4 = rhino.VectorRotate(vec1,60+rnd*10,array(0,0,1))

vec2 = rhino.VectorUnitize(tangentVec2)

vec2 = rhino.VectorScale(vec2,crvLength/8)

vecMid1 = rhino.VectorRotate(vec2,-90,array(0,0,1))

vecMid1 = rhino.VectorScale(vecMid1,0.5)

vecMid2 = rhino.VectorRotate(vec2,90,array(0,0,1))

vecMid2 = rhino.VectorScale(vecMid2,0.75)

vec3 = rhino.VectorUnitize(tangentVec3)

vec3 = rhino.VectorScale(vec3,crvLength/10)

vecEnd1 = rhino.VectorRotate(vec3,-60-rnd*10,array(0,0,1))

vecEnd2 = rhino.VectorRotate(vec3,-50+rnd*10,array(0,0,1))

vecEnd3 = rhino.VectorRotate(vec3,50-rnd*10,array(0,0,1))

vecEnd4 = rhino.VectorRotate(vec3,60+rnd*10,array(0,0,1))

pt1 = rhino.PointAdd(ptA,vecStart1)

pt2 = rhino.PointAdd(ptA,vecStart2)

pt3 = rhino.PointAdd(ptA,vecStart3)

pt4 = rhino.PointAdd(ptA,vecStart4)

pt5 = rhino.PointAdd(ptB,vecMid1)

pt6 = rhino.PointAdd(ptB,vecMid2)

pt7 = rhino.PointAdd(ptC,vecEnd1)

pt8 = rhino.PointAdd(ptC,vecEnd2)

pt9 = rhino.PointAdd(ptC,vecEnd3)

pt10 = rhino.PointAdd(ptC,vecEnd4)

crv = rhino.AddCurve(array(pt1,pt2,pt3,pt4,pt5,pt7,pt8,pt9,pt10,pt6,pt1))

srf = rhino.AddPlanarSrf(array(crv))

rhino.DeleteObject crv

hole = srf

End Function

MEGAN MAGRAW & SHUANG XU_script

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version 2009年11月15日 14:52:07

Call Main()

Sub Main()

Dim arrline,i

arrline=rhino.GetObjects(“lines”,4)

For i=0 To ubound(arrline)

Call addballs(arrline(i))

Next

End Sub

Function addballs(line)

Dim number,length, divpt,i,sphere

length=rhino.CurveLength(line)

If length>220 Then

number=int(length*0.015)+1

divpt=rhino.DivideCurve(line,number)

For i = 0 To ubound(divpt)

sphere= rhino.AddSphere(divpt(i),rnd*18+17)

sphere=rhino.scaleobject(sphere,divpt(i),array(1,1,1.2))

Next

End If

End Function

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version 2009年11月5日 9:35:25

Call Main()

Sub Main()

Dim lines, number, i,circle,factor,attr,radius

lines=rhino.GetObjects(“lines”,4)

circle=rhino.GetObject(“circle”,4)

attr=rhino.GetObject(“attractor”,1)

number=rhino.GetInteger(“numer of division”,20)

radius=rhino.GetReal(“radius”,1000)

For i =0 To ubound(lines)-1 Step 2

Call branch(lines(i),lines(i+1),number,circle,attr,radius)

Next

End Sub

Function branch(line1,line2,number,circle,attr,radius)

Dim divpt1,divpt2,i, branch1(),branch2(),k, midpt,branch3,branch4,strpt1,strpt2,line,midpt1,branch5,branch6

divpt1=rhino.DivideCurve(line1,number)

divpt2=rhino.DivideCurve(line2,number)

strpt1=rhino.CurveStartPoint(line1)

strpt2=rhino.CurveStartPoint(line2)

line=rhino.AddLine(strpt1,strpt2)

midpt=rhino.curvemidpoint(line)

Call rhino.DeleteObject(line)

For i = 0 To fix(number/3)-2 Step 2

ReDim Preserve branch1(i)

ReDim Preserve branch2(i)

branch1(i)=rhino.AddCurve(array(divpt1(3*i),divpt1(3*i+1),divpt2(3*i+2),divpt2(3*i+3)))

branch2(i)=rhino.AddCurve(array(divpt2(3*i+3),divpt2(3*i+4),divpt1(3*i+5),divpt1(3*i+6)))

Next

midpt1=rhino.CurveMidPoint(branch1(0))

branch3=rhino.AddCurve(array(midpt,midpt1,divpt1(3),divpt1(4)))

branch4=rhino.AddCurve(array(midpt,midpt1,divpt2(3),divpt2(4)))

For k = 0 To ubound(branch1)-3

branch5=rhino.AddCurve(array(divpt1(4+6*k),divpt1(5+6*k),rhino.CurveMidPoint(branch1(2*k+2)),divpt1(9+6*k),ptout(divpt1(10+6*k),midpt,circle,30*ubound(divpt1))))

branch6=rhino.AddCurve(array(divpt2(4+6*k),divpt2(5+6*k),rhino.CurveMidPoint(branch1(2*k+2)),divpt2(9+6*k),divpt2(10+6*k)))

Next

Dim dens

dens=joinarray(divpt1,divpt2)

Call density(dens,attr,radius)

End Function

Function ptout(pt,midpt,circle,factor)

Dim vector,param,closestpt

param=rhino.CurveClosestPoint(circle,midpt)

closestpt=rhino.EvaluateCurve(circle,param)

vector=rhino.VectorCreate(closestpt,midpt)

vector=rhino.VectorScale(rhino.VectorUnitize(vector),factor)

ptout=rhino.PointAdd(pt,vector)

End Function

Function density(arrpt,pt,radius)

Dim distance, arrden(),ptcood,k,n,i

ptcood=rhino.PointCoordinates(pt)

n=0

For k=0 To ubound(arrpt)

distance=rhino.distance(arrpt(k),ptcood)

If distance<radius Then

ReDim Preserve arrden(n)

arrden(n)=arrpt(k)

n=n+1

End If

Next

If n=0 Then

exit function

Else

For i =0 To ubound(arrden)-2 step 2

Call rhino.addinterpcurve(array(arrden(i),arrden(i+1),arrden(i+2)))

Next

End If

End Function

Function joinarray(arr1,arr2)

Dim collect(),i,n,m

m=0

n=0

For i =0 To ubound(arr1)*2+1

ReDim Preserve collect(i)

If  i Mod 2 = 0 Then

collect(i)=arr1(n)

n=n+1

Else

collect(i)=arr2(m)

m=m+1

End If

Next

joinarray=collect

End Function

Option Explicit

‘Script written by shuang xu

‘Script copyrighted by <insert company name>

‘Script version 2009年10月13日 10:46:42

Call Main()

Sub Main()

Dim pt, pts, arrpts(),center,i,srf, k, base, radius, factor

pt=rhino.GetObjects(“pt”,1)

pts=rhino.GetObjects(“pts”,1)

radius=rhino.GetReal(“radius”,700)

factor=rhino.GetReal(“factor”,0.8)

For i =0 To ubound(pts)

ReDim Preserve arrpts(i)

arrpts(i)=rhino.PointCoordinates(pts(i))

Next

For k = 0 To ubound(pt)

Call curve(pt(k),arrpts,radius,factor)

Next

End Sub

Function curve(pt,arrpts,radius,factor)

Dim start, j, collect_3,collect(), N, collect_final(),base

start=rhino.PointCoordinates(pt)

base=rhino.PointCoordinates(pt)

Do

ReDim Preserve collect(3*N+2)

collect_3=all(base,arrpts,radius,factor)

If  collect_3(0)(0) = 0  Then Exit Do

collect(3*N)=collect_3(0)

collect(3*N+1)=collect_3(1)

collect(3*N+2)=collect_3(2)

base= collect_3(2)

N=N+1

Loop

For j = 0 To ubound(collect)-3

ReDim Preserve collect_final(j+1)

collect_final(0)=start

collect_final(j+1)= collect(j)

Next

curve= rhino.addcurve(collect_final)

End Function

Function all(pt,ptsall,radius,factor)

Dim center, srf, arrpts, pts

center=f_nearestAbove(pt, ptsall)

If IsNull(center) Then

all = array(array(0,0,0),array(0,0,0),array(0,0,0))

Else

srf = srfonpt(center,radius,factor)

all = intersectpts(pt,center,srf)

End If

End Function

Function srfonpt(pt,radius,factor)

Dim sphere

sphere=Rhino.Addsphere(pt, radius)

srfonpt=rhino.ScaleObject(sphere,pt,array(1,factor,1))

End Function

Function f_nearestAbove(pt, ptsall)

f_nearestAbove = Null

Dim i, dist, distmin, center, srf, arrpts

distmin = 1000000000000000

For i = 0 To Ubound(ptsall)

dist = rhino.Distance(pt, ptsall(i))

If dist < distmin And ptsall(i)(2)>pt(2) Then

distmin = dist

f_nearestAbove = ptsall(i)

End If

Next

End Function

Function intersectpts(pt1,pt2,srf)

Dim line, intpts, ptonsrf1,i, circle,divcircle

line=rhino.AddLine(pt1,pt2)

line=rhino.ScaleObject(line,pt1,array(10,10,10),False)

intpts=rhino.curvesurfaceintersection(line,srf)

circle=rhino.addcircle(rhino.MovePlane(worldXYplane, pt2),700)

divcircle=rhino.DivideCurve(circle,50)

ptonsrf1=divcircle(Int(rnd*49))

If ubound(intpts) = 0 Then

intersectpts=array(pt1,ptonsrf1,intpts(0,1))

End If

If ubound(intpts) = 1 Then

intersectpts=array(intpts(0,1),ptonsrf1,intpts(1,1))

End If

Call rhino.DeleteObject(line)

Call rhino.DeleteObject(srf)

Call rhino.DeleteObject(circle)

End Function

Option Explicit

‘Script written by Shuang Xu

Call Main()

Sub Main()

Dim arrcontext, i, arrbln

arrcontext=rhino.getobjects(“context”,4)

For i= 0 To ubound(arrcontext)

arrbln= squeeze(arrcontext(i))

Next

End Sub

Function squeeze(strcurve)

Dim i,arrdivpt, RADIUS, length , divnumber,fact,k

length=rhino.CurveLength(strcurve)

divnumber=Int(length/300+5)

fact=length/250+20

arrdivpt=rhino.DivideCurve(strcurve,divnumber)

Dim arrparam(),arrnormal(),arrplane(),arrcircle()

For i=0 To divnumber

ReDim Preserve arrparam(divnumber)

ReDim Preserve arrnormal(divnumber)

ReDim Preserve arrplane(divnumber)

ReDim Preserve arrcircle(divnumber)

radius=rnd*fact+fact

arrparam(i)=rhino.CurveClosestPoint(strcurve,arrdivpt(i))

arrnormal(i)=rhino.CurveCurvature(strcurve,arrparam(i))(1)

arrplane(i)=rhino.PlaneFromNormal(arrdivpt(i),arrnormal(i))

arrcircle(i)=rhino.AddCircle(arrplane(i),radius)

Next

Call rhino.addloftsrf(arrcircle)

Call rhino.DeleteObjects(arrcircle)

End Function

NICOLE ACARON TORO_script

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version Wednesday, November 18, 2009 3:17:27 AM

Call Main()

Sub Main()

Dim crvs, i

crvs = Rhino.GetObjects(“curves”, 4)

Rhino.EnableRedraw False

For i = 0 To UBound(crvs) Step 2

Rhino.SelectObject crvs(i)

‘Rhino.EnableObjectGrips crvs(i)

Next

Rhino.EnableRedraw True

End Sub

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version Sunday, November 15, 2009 5:07:25 PM

Call Main()

Sub Main()

Dim line, lines, arrAttPts, threshold, i, arrCenterPt, attValue, arrAttScale

Dim helix, stPt

lines = Rhino.GetObjects(“select curves”, 4)

If IsNull(lines) Then Exit Sub

Call Rhino.EnableRedraw(False)

For Each line In lines

Call curveDiv(line, arrAttPts, threshold)

‘Call curveDiv2(line, arrAttPts, threshold)

‘Call curveDiv3(line, arrAttPts, threshold)

Next

Call Rhino.EnableRedraw(True)

‘draw helix curves (not all the way through the bottom)

‘enable object grips

‘move first OR LAST? grip to base points

End Sub

Function curveDiv(line, arrAttPts, threshold)

‘ subdivide curve

Dim crvPoints, arrCrvPoints, dblTangPar, crvTangs, intPlane, intPlanePt, i, arrCircles, j, radius, Count, rad()

Dim crvDomain, circRotation, angle(), rotation

crvDomain = Rhino.CurveDomain(line)

crvPoints = Rhino.DivideCurve(line, 70) ‘ 80

radius = 0.05

Dim numbCircles : numbCircles = 69 ‘79

Dim arrCirclesAll(), n : n = 0

For i = 0 To numbCircles

arrCrvPoints = Rhino.AddPoint(crvPoints(i))

arrCrvPoints = Rhino.PointCoordinates(arrCrvPoints)

dblTangPar = Rhino.CurveClosestPoint(line, arrCrvPoints)

crvTangs = Rhino.CurveTangent(line, dblTangPar)

If i < 30 Then

radius = radius + 0.005

ElseIf i >= 30 And i < 50 Then

radius = radius

Else

radius = (radius – 0.005)

End If

intPlane = Rhino.PlaneFromNormal(arrCrvPoints, crvTangs)

‘intPlane = Rhino.PlaneFromPoints(arrCrvPoints, Array(-arrCrvPoints(0)+0.8*Rnd, arrCrvPoints(1)+0.5, -2),Array(arrCrvPoints(0), arrCrvPoints(1)+0.3*Rnd, 1) )

ReDim Preserve arrCirclesAll(n)

arrCirclesAll(n) = Rhino.AddEllipse(intPlane, radius, radius)

n = n +1

‘If i < 60 Then

rotation = rotation + 90

circRotation = Rhino.RotateObject(arrCirclesAll(i), arrCrvPoints, rotation ,crvTangs , False)

‘End If

Next

Call interpolatedHelix(arrCirclesAll, crvTangs, arrCrvPoints)

Call interpolatedHelix2(arrCirclesAll)

Call Rhino.DeleteObjects(arrCirclesAll)

End Function

Function curveDivStraight(line, arrAttPts, threshold)

‘ subdivide curve

Dim crvPoints, arrCrvPoints, dblTangPar, crvTangs, intPlane, intPlanePt, i, arrCircles, j, radius, Count, rad()

Dim crvDomain, circRotation, angle(), rotation

crvDomain = Rhino.CurveDomain(line)

crvPoints = Rhino.DivideCurve(line, 70) ‘ 80

radius = 0.05

Dim numbCircles : numbCircles = 69 ‘79

Dim arrCirclesAll(), n : n = 0

For i = 0 To numbCircles

arrCrvPoints = Rhino.AddPoint(crvPoints(i))

arrCrvPoints = Rhino.PointCoordinates(arrCrvPoints)

dblTangPar = Rhino.CurveClosestPoint(line, arrCrvPoints)

crvTangs = Rhino.CurveTangent(line, dblTangPar)

If i < 30 Then

radius = radius + 0.005

ElseIf i >= 30 And i < 50 Then

radius = radius

Else

radius = (radius – 0.005)

End If

intPlane = Rhino.PlaneFromNormal(arrCrvPoints, crvTangs)

‘intPlane = Rhino.PlaneFromPoints(arrCrvPoints, Array(-arrCrvPoints(0)+0.8*Rnd, arrCrvPoints(1)+0.5, -2),Array(arrCrvPoints(0), arrCrvPoints(1)+0.3*Rnd, 1) )

ReDim Preserve arrCirclesAll(n)

arrCirclesAll(n) = Rhino.AddEllipse(intPlane, radius, radius)

n = n +1

Next

Call interpolatedHelix(arrCirclesAll, crvTangs, arrCrvPoints)

Call interpolatedHelix2(arrCirclesAll)

Call Rhino.DeleteObjects(arrCirclesAll)

End Function

Function curveDivStraight2(line, arrAttPts, threshold)

‘ subdivide curve

Dim crvPoints, arrCrvPoints, dblTangPar, crvTangs, intPlane, intPlanePt, i, arrCircles, j, radius, Count, rad()

Dim crvDomain, circRotation, angle(), rotation

crvDomain = Rhino.CurveDomain(line)

crvPoints = Rhino.DivideCurve(line, 70) ‘ 80

radius = 0.05

Dim numbCircles : numbCircles = 69 ‘79

Dim arrCirclesAll(), n : n = 0

For i = 0 To numbCircles

arrCrvPoints = Rhino.AddPoint(crvPoints(i))

arrCrvPoints = Rhino.PointCoordinates(arrCrvPoints)

dblTangPar = Rhino.CurveClosestPoint(line, arrCrvPoints)

crvTangs = Rhino.CurveTangent(line, dblTangPar)

If i < 30 Then

radius = radius + 0.005

ElseIf i >= 30 And i < 50 Then

radius = radius

Else

radius = (radius – 0.005)

End If

intPlane = Rhino.PlaneFromNormal(arrCrvPoints, crvTangs)

‘intPlane = Rhino.PlaneFromPoints(arrCrvPoints, Array(-arrCrvPoints(0)+0.8*Rnd, arrCrvPoints(1)+0.5, -2),Array(arrCrvPoints(0), arrCrvPoints(1)+0.3*Rnd, 1) )

ReDim Preserve arrCirclesAll(n)

arrCirclesAll(n) = Rhino.AddEllipse(intPlane, radius, radius)

n = n +1

If i < 60 Then

rotation = 180

circRotation = Rhino.RotateObject(arrCirclesAll(i), arrCrvPoints, rotation ,crvTangs , False)

End If

Next

Call interpolatedHelix(arrCirclesAll, crvTangs, arrCrvPoints)

Call interpolatedHelix2(arrCirclesAll)

Call Rhino.DeleteObjects(arrCirclesAll)

End Function

Function curveDiv2(line, arrAttPts, threshold)

‘ subdivide curve

Dim crvPoints, arrCrvPoints, dblTangPar, crvTangs, intPlane, intPlanePt, i, arrCircles, j, radius, Count, rad()

Dim crvDomain, circRotation, angle(), rotation

crvDomain = Rhino.CurveDomain(line)

crvPoints = Rhino.DivideCurve(line, 50)

radius = 0.005

Dim numbCircles : numbCircles = 49

Dim arrCirclesAll(), n : n = 0

For i = 0 To numbCircles

arrCrvPoints = Rhino.AddPoint(crvPoints(i))

arrCrvPoints = Rhino.PointCoordinates(arrCrvPoints)

dblTangPar = Rhino.CurveClosestPoint(line, arrCrvPoints)

crvTangs = Rhino.CurveTangent(line, dblTangPar)

If i < 30 Then

radius = radius + 0.01

ElseIf i >= 30 And i < 50 Then

radius = radius

Else

radius = (radius – 0.005)

End If

intPlane = Rhino.PlaneFromNormal(arrCrvPoints, crvTangs)

‘intPlane = Rhino.PlaneFromPoints(arrCrvPoints, Array(-arrCrvPoints(0)+0.8*Rnd, arrCrvPoints(1)+0.5, -2),Array(arrCrvPoints(0), arrCrvPoints(1)+0.3*Rnd, 1) )

ReDim Preserve arrCirclesAll(n)

arrCirclesAll(n) = Rhino.AddEllipse(intPlane, radius, radius)

n = n +1

‘If i < 45 Then

rotation = rotation + 60

circRotation = Rhino.RotateObject(arrCirclesAll(i), arrCrvPoints, rotation ,crvTangs , False)

‘End If

Next

Call interpolatedHelix2(arrCirclesAll, crvTangs, arrCrvPoints)

Call interpolatedHelix2(arrCirclesAll)

Call Rhino.DeleteObjects(arrCirclesAll)

End Function

Function curveDiv3(line, arrAttPts, threshold)

‘ subdivide curve

Dim crvPoints, arrCrvPoints, dblTangPar, crvTangs, intPlane, intPlanePt, i, arrCircles, j, radius, Count, rad()

Dim crvDomain, circRotation, angle(), rotation

crvDomain = Rhino.CurveDomain(line)

crvPoints = Rhino.DivideCurve(line, 40)

radius = 0.005

Dim numbCircles : numbCircles = 39

Dim arrCirclesAll(), n : n = 0

For i = 0 To numbCircles

arrCrvPoints = Rhino.AddPoint(crvPoints(i))

arrCrvPoints = Rhino.PointCoordinates(arrCrvPoints)

dblTangPar = Rhino.CurveClosestPoint(line, arrCrvPoints)

crvTangs = Rhino.CurveTangent(line, dblTangPar)

If i < 30 Then

radius = radius + 0.005

ElseIf i >= 30 And i < 50 Then

radius = radius

Else

radius = (radius – 0.005)

End If

intPlane = Rhino.PlaneFromNormal(arrCrvPoints, crvTangs)

‘intPlane = Rhino.PlaneFromPoints(arrCrvPoints, Array(-arrCrvPoints(0)+0.8*Rnd, arrCrvPoints(1)+0.5, -2),Array(arrCrvPoints(0), arrCrvPoints(1)+0.3*Rnd, 1) )

ReDim Preserve arrCirclesAll(n)

arrCirclesAll(n) = Rhino.AddEllipse(intPlane, radius, radius)

n = n +1

If i < 30 Then

rotation = rotation + 90

circRotation = Rhino.RotateObject(arrCirclesAll(i), arrCrvPoints, rotation ,crvTangs , False)

End If

Next

Call interpolatedHelix(arrCirclesAll, crvTangs, arrCrvPoints)

Call interpolatedHelix2(arrCirclesAll)

Call Rhino.DeleteObjects(arrCirclesAll)

End Function

Function interpolatedHelix(arrCrv, crvTangs, arrCrvPoints)

Dim i, divpts(), ptcollect(),j, spiral,number,k, intPlaneDivisions, divpoints

Dim Count, gripPos

number=12

For i =0 To UBound(arrcrv)

ReDim Preserve divpts(i)

divpts(i)=Rhino.DivideCurve(arrcrv(i),number)

‘k=0

For j =0 To number-1

‘If k=ubound(divpts)+1 Then

k=0

‘End If

ReDim Preserve ptcollect(i)

ptcollect(i)=divpts(i)(k)

k=k+1

Next

Next

interpolatedHelix=Rhino.addinterpcurve(ptcollect)

‘Rhino.EnableObjectGrips interpolatedHelix, True

‘intCount = Rhino.ObjectGripCount(line)

‘For j = 1 To intCount-1

‘If j = 1 Then

‘copy start point 3 times around base

gripPos = Rhino.ObjectGripLocation(interpolatedHelix, j)

gripPos(0) = gripPos(0)

‘gripPos(1) = gripPos(1)

gripPos(2) = gripPos(2)

Rhino.ObjectGripLocation interpolatedHelix, 0, gripPos

Rhino.EnableObjectGrips interpolatedHelix, False

Dim pts: pts = Rhino.ObjectsByType(1,True)

Rhino.DeleteObjects pts

End Function

Function interpolatedHelix2(arrCrv, crvTangs, arrCrvPoints)

Dim i, divpts(), ptcollect(),j, spiral,number,k, intPlaneDivisions, divpoints

Dim Count, gripPos

number=12

For i =0 To UBound(arrcrv)

ReDim Preserve divpts(i)

divpts(i)=Rhino.DivideCurve(arrcrv(i),number)

‘k=0

For j =0 To number-1

‘If k=ubound(divpts)+1 Then

k=0

‘End If

ReDim Preserve ptcollect(i)

ptcollect(i)=divpts(i)(k)

k=k+1

Next

Next

interpolatedHelix2=Rhino.addinterpcurve(ptcollect)

Rhino.EnableObjectGrips interpolatedHelix2, True

‘intCount = Rhino.ObjectGripCount(line)

‘For j = 1 To intCount-1

‘If j = 1 Then

‘copy start point 3 times around base

gripPos = Rhino.ObjectGripLocation(interpolatedHelix2, j)

gripPos(0) = gripPos(0)

gripPos(1) = gripPos(1)

gripPos(2) = gripPos(2)

Rhino.ObjectGripLocation interpolatedHelix2, 0, gripPos

Rhino.EnableObjectGrips interpolatedHelix2, False

End Function

SUKIE & SHEN_script

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version 2009年10月15日 13:40:39

Call Main()

Sub Main()

Dim h

h = rhino.GetInteger(“give the height of robot”,500)

Dim minangle,maxangle

Dim pt1,pt2

pt1 = array(0,0,0)

pt2 = array(0,0,h)

Dim robline

robline = rhino.AddLine(pt1,pt2)

Dim gen

gen = rhino.getinteger(“generation”,10)

Dim strn

strn = rhino.GetInteger(“curve dividing number”,30)

Dim ptn

ptn = rhino.getinteger(“give the dividing number of each circle”,4)

Dim stpt,edpt

stpt = Rhino.CurveStartPoint(robline)

Call rhino.AddPoint(stpt)

edpt = rhino.CurveEndPoint(robline)

Call rhino.AddPoint(edpt)

Dim lenvec

lenvec = rhino.vectorcreate(edpt,stpt)

Dim length

length = rhino.CurveLength(robline)

Dim rtvec

rtvec = rhino.PlaneFromNormal(edpt,rhino.CurveNormal(robline))

If isnull (rtvec) Then Exit Sub

Call rotatline(robline,rtvec(1),stpt,edpt,lenvec,gen)

Dim ptarray

ptarray = Rhino.ObjectsByType(1)

Dim i

For i = 0 To ubound(ptarray)

ptarray(i) = rhino.pointcoordinates(ptarray(i))

Next

ptarray = Rhino.SortPointList(ptarray)

Dim cenline

cenline = rhino.AddInterpCurve(ptarray)

ptarray(0) = stpt

‘Call rhino.AddInterpCurve(ptarray,3)

Dim arrdvpts

arrdvpts = rhino.DivideCurve(cenline,strn,True, True)

Dim l

Dim count :count = 1

Dim k,arrcircles

ReDim arrcircles(ubound(arrdvpts))

Dim dvpts()

ReDim Preserve dvpts(ptn)

Dim degree

ReDim degree(ptn)

Dim closestpt

ReDim closestpt(ptn)

Dim vector

ReDim vector(ptn)

Dim data

Dim outpts

ReDim outpts(ptn)

Dim arrnum

ReDim arrnum(ubound(arrdvpts))

For k = 0 To ubound(arrdvpts)

count = count +0.2

Dim strPoncurve: strPoncurve = rhino.CurveClosestPoint(cenline, arrdvpts(k))

Dim strframe: strframe = rhino.Curveperpframe(cenline, strPoncurve)

arrcircles(k) = rhino.addcircle(strframe,(30*sin(count*rhino.Pi)+100) )              ’(10*sin(count*rhino.Pi)

Next

For k = 0 To ubound(arrcircles)

data = rhino.CurveDomain(arrcircles(k))

arrnum(k) = array(outpts)

For l = 0 To ptn

If l = 0 Then

degree(l) = 0.5*rnd*(data(1)-data(0))/ptn

dvpts(l) = rhino.EvaluateCurve(arrcircles(k),degree(l))

outpts(l) = rhino.AddPoint(dvpts(l))

closestpt(l) = rhino.CurveClosestPoint(cenline, dvpts(l))

closestpt(l) = rhino.evaluatecurve(cenline,closestpt(l))

vector(l) = rhino.vectorcreate(dvpts(l),closestpt(l))

vector(l) = rhino.VectorScale(vector(l), (3+3*rnd))

outpts(l) = rhino.moveobject(outpts(l),vector(l))

arrnum(k)(0)(l) =rhino.PointCoordinates(outpts(l))

‘array(arrnum(k),outpts(l))= rhino.PointCoordinates(outpts(l))

‘outpts(l) = rhino.PointCoordinates(outpts(l))

arraypoints(1)(l) = outpts(l)

End If

If l > 0 And l < ptn Then

degree(l) = (l-0.5+rnd)*(data(1)-data(0))/ptn

dvpts(l) = rhino.EvaluateCurve(arrcircles(k),degree(l))

outpts(l) = rhino.AddPoint(dvpts(l))

closestpt(l) = rhino.CurveClosestPoint(cenline, dvpts(l))

closestpt(l) = rhino.evaluatecurve(cenline,closestpt(l))

vector(l) = rhino.vectorcreate(dvpts(l),closestpt(l))

vector(l) = rhino.VectorScale(vector(l), (3+3*rnd))

outpts(l) = rhino.moveobject(outpts(l),vector(l))

‘outpts(l) = rhino.PointCoordinates(outpts(l))

arrnum(k)(0)(l) =rhino.PointCoordinates(outpts(l))

‘array(arrnum(k),outpts(l))= rhino.PointCoordinates(outpts(l))

arraypoints(1)(l) = outpts(l)

End If

If l = ptn Then

degree(l) = (l-0.5+0.5*rnd)*(data(1)-data(0))/ptn

dvpts(l) = rhino.EvaluateCurve(arrcircles(k),degree(l))

outpts(l) = rhino.AddPoint(dvpts(l))

closestpt(l) = rhino.CurveClosestPoint(cenline, dvpts(l))

closestpt(l) = rhino.evaluatecurve(cenline,closestpt(l))

vector(l) = rhino.vectorcreate(dvpts(l),closestpt(l))

vector(l) = rhino.VectorScale(vector(l), (3+3*rnd))

outpts(l) = rhino.moveobject(outpts(l),vector(l))

‘outpts(l) = rhino.PointCoordinates(outpts(l))

arrnum(k)(0)(l) =rhino.PointCoordinates(outpts(l))

array(arrnum(k),outpts(l))= rhino.PointCoordinates(outpts(l))

arraypoints(1)(l) = outpts(l)End If

End If

Next

Next

For k = 0 To ubound(arrnum)-1

For l = 0 To ptn-1

Call rhino.AddPolyline(array(arrnum(k)(0)(l),arrnum(k+1)(0)(l),arrnum(k)(0)(l+1),arrnum(k)(0)(l)))

Call rhino.AddPolyline(array(arrnum(k)(0)(l+1),arrnum(k+1)(0)(l),arrnum(k+1)(0)(l+1),arrnum(k)(0)(l+1)))

Next

Call rhino.AddPolyline(array(arrnum(k)(0)(ptn),arrnum(k+1)(0)(ptn),arrnum(k)(0)(0),arrnum(k)(0)(ptn)))

Call rhino.AddPolyline(array(arrnum(k)(0)(0),arrnum(k+1)(0)(ptn),arrnum(k+1)(0)(0),arrnum(k)(0)(0)))

Next

Call rhino.DeleteObjects(arrcircles)

Dim loftsrf

loftsrf = rhino.addloftsrf(arrcircles)

End Sub

Function rotatline(robline,rtvec,stpt,edpt,lenvec,gen)

Dim line

line = rhino.CopyObject(robline,stpt,edpt)

line  = rhino.RotateObject(line,edpt,(-30+rnd*60),rtvec)

Dim endpt

endpt = rhino.CurveEndPoint(line)

Dim startpt

startpt = rhino.CurveStartPoint(line)

Dim endvec

endvec = rhino.PlaneFromNormal(endpt,rhino.CurveNormal(line))

Dim lvec

lvec = rhino.VectorCreate(endpt,startpt)

ptarray(n) = startpt

n = n+1

gen = gen -1

If gen = 0 Then Exit Function

Dim a

a = rnd*1

Dim line2

Dim spt

Dim ept

Dim lenvec2

Dim rtvec2

If a < 0.33 Then

line2 = rhino.RotateObject(line,startpt,120,lenvec)

spt = rhino.CurveStartPoint(line2)

ept = rhino.CurveEndPoint(line2)

lenvec2 = rhino.VectorCreate(ept,spt)

rtvec2 = rhino.PlaneFromNormal(ept,rhino.CurveNormal(line2))

Call rhino.AddPoint(ept)

Call rotatline(line2,rtvec2(1),spt,ept,lenvec2,gen)

End If

If a > 0.33 And a < 0.66 Then

line2 = rhino.RotateObject(line,startpt,240,lenvec)

spt = rhino.CurveStartPoint(line2)

ept = rhino.CurveEndPoint(line2)

lenvec2 = rhino.VectorCreate(ept,spt)

rtvec2 = rhino.PlaneFromNormal(ept,rhino.CurveNormal(line2))

Call rhino.AddPoint(ept)

Call rotatline(line2,rtvec2(1),spt,ept,lenvec2,gen)

End If

If a > 0.66 And a<1 Then

Call rhino.AddPoint(endpt)

Call rotatline(line,endvec(1),startpt,endpt,lvec,gen)

End If

End Function

Option Explicit

‘Script written by <insert name>

‘Script copyrighted by <insert company name>

‘Script version 2009年11月6日 0:39:25

Call Main()

Sub Main()

Dim strn

strn = rhino.GetInteger(“curve dividing number”,20)

Dim ptn

ptn = rhino.getinteger(“give the dividing number of each circle”,5)

Dim noise

noise = rhino.getinteger(“give the z direction deviation for the points”,20)

Dim u

Dim arrcenline

arrcenline = rhino.GetObjects(“pick the curves to transform”, 4)

Dim arratt

arratt = rhino.getobjects(“get all the attractors”,1)

Dim y

For y = 0 To ubound(arratt)

arratt(y) = rhino.PointCoordinates(arratt(y))

Next

Dim l

Dim arrdvpts

Dim dvpts()

ReDim Preserve dvpts(ptn)

Dim degree

ReDim degree(ptn)

Dim closestpt

ReDim closestpt(ptn)

Dim vector

ReDim vector(ptn)

Dim data

Dim outpts

ReDim outpts(ptn)

Dim allcurves

Dim arrlayer

ReDim arrlayer(ubound(arrcenline))

Dim count1:count1 = 0

For u = 0 To ubound(arrcenline)

arrdvpts = rhino.DivideCurve(arrcenline(u),strn,True, True)

Dim count :count = 1

Dim k,arrcircles

ReDim arrcircles(ubound(arrdvpts))

Dim arrnum

ReDim arrnum(ubound(arrdvpts))

For k = 0 To ubound(arrdvpts)

count = count +0.2

Dim closestpt1,index

index = rhino.PointArrayClosestPoint(arratt,arrdvpts(k))

closestpt1 = arratt(index)

Dim distance

distance = rhino.distance (arrdvpts(k),closestpt1)

Dim strPoncurve: strPoncurve = rhino.CurveClosestPoint(arrcenline(u), arrdvpts(k))

Dim strframe: strframe = rhino.Curveperpframe(arrcenline(u), strPoncurve)

arrcircles(k) = rhino.addcircle(strframe,10+ distance/25)               ‘(10*sin(count*rhino.Pi)  30*sin(count*rhino.Pi)+40+

Next

‘——————————————————————————-generate the points

Dim vecscale

vecscale = 3+3*rnd

For k = 0 To ubound(arrcircles)

data = rhino.CurveDomain(arrcircles(k))

arrnum(k) = array(outpts)

For l = 0 To ptn

If l = 0 Then

degree(l) = 0.5*rnd*(data(1)-data(0))/ptn

dvpts(l) = rhino.EvaluateCurve(arrcircles(k),degree(l))

outpts(l) = rhino.AddPoint(dvpts(l))

closestpt(l) = rhino.CurveClosestPoint(arrcenline(u), dvpts(l))

closestpt(l) = rhino.evaluatecurve(arrcenline(u),closestpt(l))

vector(l) = rhino.vectorcreate(dvpts(l),closestpt(l))

vector(l) = rhino.VectorScale(vector(l), (0.8+0.3*rnd))

outpts(l) = rhino.moveobject(outpts(l),vector(l))

outpts(l) = rhino.PointCoordinates(outpts(l))

arrnum(k)(0)(l) = array(outpts(l)(0) + rnd*randomWithinRange(-noise,noise),outpts(l)(1) + rnd*randomWithinRange(-noise,noise),outpts(l)(2) + rnd*randomWithinRange(-noise,noise))

End If

If l > 0 And l < ptn Then

degree(l) = (l-0.5+rnd)*(data(1)-data(0))/ptn

dvpts(l) = rhino.EvaluateCurve(arrcircles(k),degree(l))

outpts(l) = rhino.AddPoint(dvpts(l))

closestpt(l) = rhino.CurveClosestPoint(arrcenline(u), dvpts(l))

closestpt(l) = rhino.evaluatecurve(arrcenline(u),closestpt(l))

vector(l) = rhino.vectorcreate(dvpts(l),closestpt(l))

vector(l) = rhino.VectorScale(vector(l), (0.8+0.3*rnd))

outpts(l) = rhino.moveobject(outpts(l),vector(l))

outpts(l) = rhino.PointCoordinates(outpts(l))

arrnum(k)(0)(l) = array(outpts(l)(0) + rnd*randomWithinRange(-noise,noise),outpts(l)(1) + rnd*randomWithinRange(-noise,noise),outpts(l)(2) + rnd*randomWithinRange(-noise,noise))

End If

If l = ptn Then

degree(l) = (l-0.5+0.5*rnd)*(data(1)-data(0))/ptn

dvpts(l) = rhino.EvaluateCurve(arrcircles(k),degree(l))

outpts(l) = rhino.AddPoint(dvpts(l))

closestpt(l) = rhino.CurveClosestPoint(arrcenline(u), dvpts(l))

closestpt(l) = rhino.evaluatecurve(arrcenline(u),closestpt(l))

vector(l) = rhino.vectorcreate(dvpts(l),closestpt(l))

vector(l) = rhino.VectorScale(vector(l), (0.8+0.3*rnd))

outpts(l) = rhino.moveobject(outpts(l),vector(l))

outpts(l) = rhino.PointCoordinates(outpts(l))

arrnum(k)(0)(l) = array(outpts(l)(0) + rnd*randomWithinRange(-noise,noise),outpts(l)(1) + rnd*randomWithinRange(-noise,noise),outpts(l)(2) + rnd*randomWithinRange(-noise,noise))

End If

Next

Next

‘————————————————————————- generate the trianglate polyline based on the points above

Dim pline1,pline2,pline3,pline4

ReDim pline1(k*(l-1))

ReDim pline2(k*(l-1))

ReDim pline3(k)

ReDim pline4(k)

For k = 0 To ubound(arrnum)-1

For l = 0 To ptn-1

pline1(k*ptn+l) = rhino.AddPolyline(array(arrnum(k)(0)(l),arrnum(k+1)(0)(l),arrnum(k)(0)(l+1),arrnum(k)(0)(l)))

pline2(k*ptn+l) =  rhino.AddPolyline(array(arrnum(k)(0)(l+1),arrnum(k+1)(0)(l),arrnum(k+1)(0)(l+1),arrnum(k)(0)(l+1)))

Next

pline3(k)=  rhino.AddPolyline(array(arrnum(k)(0)(ptn),arrnum(k+1)(0)(ptn),arrnum(k)(0)(0),arrnum(k)(0)(ptn)))

pline4(k) =  rhino.AddPolyline(array(arrnum(k)(0)(0),arrnum(k+1)(0)(ptn),arrnum(k+1)(0)(0),arrnum(k)(0)(0)))

Next

Call rhino.AddLoftSrf(arrcircles)

Call rhino.DeleteObjects(arrcircles)

Dim deletepts

deletepts = rhino.ObjectsByType(1)

Call rhino.deleteobjects(deletepts)

allcurves = rhino.ObjectsByType(4)

rhino.Command “_group”

Next

End Sub

Function randomWithinRange(min, max)

Randomize

randomWithinRange = min + (max-min) * rnd()

End Function