A pool of resources
Lattice Pipe

    


This Rhino Script allows the user to create an oscillating lattice of curves.  The user is asked to select a curve to act as a rail.  The user can then select the number of strands which will oscialate around the rail, the number of points of contact and an overall torsion if desired.  In addition the user can select a minimum and maxium radius of oscillation as well as the number of times it will move between these two radai.


platform: Rhino Script
function: Modeling Aid

 


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


Reply