geometry.lattice pipe.01

Option Explicit
‘Script written by
‘Script copyrighted by
‘Script version Sunday, August 30, 2009 1:22:47 AM

Call Main()
Sub Main()
Dim strCurve
strCurve = Rhino.GetObject(“Select Curve”,4,True)
If isNull(strCurve) Then Exit Sub
Call reparameterize(strCurve)

Dim arrItems, arrValues, arrReturns
arrItems = array(“Strands”,”Rotations”,”Strand Oscillations”,”Min Radius”,”Max Radius”,”Radius Oscillations”,”Samples”)
arrValues= array(8,0,4,1,2,4,18)
arrReturns = Rhino.PropertyListBox (arrItems, arrValues ,,”Parameters”)
If isNull(arrReturns) Then Exit Sub

Call Rhino.EnableRedraw(False)
Call curveLattice(strCurve,CInt(arrReturns(0)),CInt(arrReturns(2)),CDbl(arrReturns(1)),array(CDbl(arrReturns(3)),CDbl(arrReturns(4))),CInt(arrReturns(5)),CInt(arrReturns(6)))
Call Rhino.EnableRedraw(True)

End Sub
Function curveLattice(strCurve,intStrands,intOscillations, dblRotation, arrRadius, intRadius, intSamples)
curveLattice = Null
intOscillations = intOscillations*2

Dim i,j, count, tDom, tStep, rStep, dblSc
Dim tFrame, rFrame
Dim arrOutput(),arrPt()

count = intSamples*intOscillations
ReDim arrPt(count), arrOutput(intStrands)

tDom = Rhino.CurveDomain(strCurve)
tStep = (tDom(1)-tDom(0))/count
rStep = 360/intStrands
dblSc = arrRadius(1)-arrRadius(0)

For i = 0 To intStrands-1 Step 1
For j = 0 To count Step 1
tFrame = Rhino.CurvePerpFrame(strCurve,tDom(0)+tStep*j)
If i Mod(2) Then
rFrame = Rhino.RotatePlane(tFrame,rStep*i+(rStep*0.5)*sin(intOscillations*PI*(j/count))+(360*dblRotation)*j/count,tFrame(3))
rFrame = Rhino.RotatePlane(tFrame,rStep*i+(rStep*0.5)*sin(PI+intOscillations*PI*(j/count))+(360*dblRotation)*j/count,tFrame(3))
End If
arrPt(j) = Rhino.PointAdd(tFrame(0),Rhino.VectorScale(Rhino.VectorUnitize(rFrame(1)),arrRadius(0)+dblSc+dblSc*cos(intRadius*PI*(j/count))))
arrOutput(i) = arrPt
Call Rhino.AddInterpCurve(arrPt)

curveLattice = arrOutput
End Function
Function reparameterize(strObjectID)
If Rhino.IsCurve(strObjectID) = True Then
Call rhino.SelectObject(strObjectID)
Call rhino.Command(“reparameterize 0 1”)
Call rhino.UnselectAllObjects()
End If
If Rhino.IsSurface(strObjectID) = True Then
Call rhino.SelectObject(strObjectID)
Call rhino.Command(“reparameterize 0 1 0 1”)
Call rhino.UnselectAllObjects()
End If
End Function


There are no comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: