Lattice Pipe
Option Explicit
'Script written by <David Mans>
'Script copyrighted by <NeoArchaic Studio>
'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))
Else
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))))
Next
arrOutput(i) = arrPt
Call Rhino.AddInterpCurve(arrPt)
Next
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
Không có nhận xét nào:
Đăng nhận xét