Fabrication Data For Surface Weaving

This RhinoScript takes an input surface and cross-section curves and weaves fibres with the given cross-sections along that surface. The user can specify the ‘thread count’ and the tightness of the weave (weave factor). If prompted by the user, the script can also generate fabrication data specifying the distances between intersections with other fibres along the length of each woven fibre. I hope to use this script to create some physical models in the near future.
A Screen Shot Showing the Use of Multiple Cross-Sections and the Fabrication Data Output
An Experiment With a Hexagonal Weaving Pattern
Option Explicit
‘Script written by <Ayodh Kamath>
‘Script copyrighted by <Ayodh Kamath>
‘Script version Thursday, 27 May 2010 10:30:20
Call Main()
Sub Main()
Dim strSrf, arrUDomain, arrVDomain, intUdiv, intVdiv, dblWeaveFactor, dblWeaveFactorU, dblWeaveFactorV
Dim i, j
Dim strSecCrvU, strSecCrvV, arrBox
Dim dblFabChoice, strLengthCount
ReDim arrOrientPts1(2)
ReDim arrOrientPts2(2)
arrOrientPts1(0) = Array(0,0,0)
arrOrientPts1(1) = Array(1,0,0)
arrOrientPts1(2) = Array(0,1,0)
strSrf = Rhino.GetObject(“Select surface”, 8 )
arrUDomain = Rhino.SurfaceDomain(strSrf, 0)
arrVDomain = Rhino.SurfaceDomain(strSrf, 1)
intUdiv = Rhino.GetInteger(“Enter number of threads in U:”)
intUdiv = intUdiv – 1
intVdiv = Rhino.GetInteger(“Enter number of threads in V:”)
intVdiv = intVdiv – 1
strSecCrvU = Rhino.GetObject(“Select cross section curve in the U direction”, 4)
arrBox = Rhino.BoundingBox(strSecCrvU)
dblWeaveFactorU = Rhino.Distance(arrBox(1), arrBox(2))/2
dblWeaveFactorU = Rhino.GetReal(“Enter the weave factor in the U direction:”, dblWeaveFactorU)
strSecCrvV = Rhino.GetObject(“Select cross section curve in the V direction”, 4)
arrBox = Rhino.BoundingBox(strSecCrvV)
dblWeaveFactorV = Rhino.Distance(arrBox(1), arrBox(2))/2
dblWeaveFactorV = Rhino.GetReal(“Enter the weave factor in the V direction:”, dblWeaveFactorV)
ReDim arrPts(intUdiv, intVdiv)
ReDim arrPtsU(intUdiv, intVdiv)
ReDim arrPtsV(intUdiv, intVdiv)
ReDim arrNorm(intUdiv, intVdiv)
ReDim arrNormU(intUdiv, intVdiv)
ReDim arrNormV(intUdiv, intVdiv)
ReDim arrParamsU(intUdiv)
ReDim arrParamsV(intVdiv)
ReDim arrCrvsU(intVdiv)
ReDim arrCrvsV(intUdiv)
ReDim arrPlinesU(intUdiv)
ReDim arrPlinesV(intVdiv)
For i = 0 To intUdiv
For j = 0 To intVdiv
arrParamsU(i) = i*(arrUDomain(0)+arrUDomain(1))/intUdiv
arrParamsV(j) = j*(arrVDomain(0)+arrVDomain(1))/intVdiv
arrPts(i,j) = Rhino.EvaluateSurface(strSrf, Array(arrParamsU(i), arrParamsV(j)))
arrNorm(i,j) = Rhino.SurfaceNormal(strSrf, Array(arrParamsU(i), arrParamsV(j)))
arrNorm(i,j) = Rhino.VectorUnitize(arrNorm(i,j))
If (i Mod 2) =  0 Or i = 0 Then
If (j Mod 2) = 0 Or j = 0 Then
arrNorm(i,j) = Rhino.VectorReverse(arrNorm(i,j))
End If
If (j Mod 2) <> 0 And j <> 0 Then
arrNorm(i,j) = Rhino.VectorReverse(arrNorm(i,j))
End If
End If
arrNormU(i,j) = Rhino.VectorScale(arrNorm(i,j), dblWeaveFactorU)
arrPtsU(i,j) = Rhino.VectorAdd(arrPts(i,j), arrNormU(i,j))
Call Rhino.CurrentLayer(“Layer 01”)
Call Rhino.AddPoint(arrPtsU(i,j))
arrNormV(i,j) = Rhino.VectorScale(arrNorm(i,j), dblWeaveFactorV)
arrPtsV(i,j) = Rhino.VectorAdd(arrPts(i,j), Rhino.VectorReverse(arrNormV(i,j)))
Call Rhino.CurrentLayer(“Layer 02”)
Call Rhino.AddPoint(arrPtsV(i,j))
For i = 0 To intUdiv
ReDim arrPlinePts(intVdiv)
For j = 0 To intVdiv
arrPlinePts(j) = arrPtsU(i,j)
Call Rhino.CurrentLayer(“Layer 03”)
arrPlinesU(i) = Ribbon(arrPlinePts, strSecCrvU)
For i = 0 To intVdiv
ReDim arrPlinePts(intUdiv)
For j = 0 To intUdiv
arrPlinePts(j) = arrPtsV(j,i)
Call Rhino.CurrentLayer(“Layer 04”)
arrPlinesV(i) = Ribbon(arrPlinePts, strSecCrvV)
dblFabChoice = Rhino.MessageBox(“Do you want to create fabrication data?”,1)
If dblFabChoice = 1 Then
For i = 0 To intUdiv
Call Rhino.AddTextDot(“U”&CStr(i), arrPtsU(i,0))
strLengthCount = “U”&CStr(i)&”: “
For j = 0 To intVdiv-1
strLengthCount = strLengthCount&CStr(Unroll(arrPlinesU(i), arrPtsU(i,j), arrPtsU(i,j+1)))&”,”
Call Rhino.TextOut(strLengthCount)
For i = 0 To intVdiv
Call Rhino.AddTextDot(“V”&CStr(i), arrPtsV(0,i))
strLengthCount = “V”&CStr(i)&”: “
For j = 0 To intUdiv-1
strLengthCount = strLengthCount&CStr(Unroll(arrPlinesV(i), arrPtsV(j,i), arrPtsV(j+1,i)))&”,”
Call Rhino.TextOut(strLengthCount)
End If
End Sub
Function Ribbon(arrPts, strSectionCrv)
End Function
Function Unroll(strCrv, arrPt1, arrPt2)
End Function

3 thoughts on “Fabrication Data For Surface Weaving

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s