071005_M.Bearak_Meshing

robot :: perception

Man + Machine + well, another machine…

meshstructure.jpg

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Friday, October 05, 2007 10:54:37 AM

Call Main()
Sub Main()

Dim i,j, k
Dim u,v
Dim arrPoint

Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim intU : intU = 22 ‘Horizontal
Dim intV : intV = 24 ‘Vertical
Dim UDomain : UDomain = Rhino.SurfaceDomain(strSrf, 0)
Dim VDomain : VDomain = Rhino.SurfaceDomain(strSrf, 1)
Dim UStep : UStep = (UDomain(1) – UDomain(0)) / intU
Dim VStep : VStep = (VDomain(1) – VDomain(0)) / intV
ReDim arrFrame(intU,intV)
ReDim arrPts(intU,intV)

Dim strCrv, strCrvb, arrPlane, arrPtNormal, dblRadius
Dim arrCircle(), arrCircleb()

dblRadius = .3
For i = 0 To intU
For j = 0 To intV
u = UDomain(0) + UStep * i
v = VDomain(0) + vStep * j
arrFrame(i,j) = Rhino.SurfaceFrame (strSrf, array(U,V))
Call Rhino.AddPoints (array(arrFrame(i,j)(0)))
If (i > 1)And (i Mod 2 = 0) And (j>23) Then
k = ((intU+1) – i)/40
ReDim Preserve arrCircle(12)
ReDim Preserve arrCircleb(12)
arrPtNormal = Rhino.PointAdd(arrFrame(i,j)(0), Rhino.VectorScale (arrFrame(i,j)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j)(0), arrFrame(i-1,j)(0), arrPtNormal)
arrCircle(0) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-2)(0), Rhino.VectorScale (arrFrame(i-1,j-2)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-2)(0), arrFrame(i-2,j-2)(0), arrPtNormal)
arrCircle(1) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-4)(0), Rhino.VectorScale (arrFrame(i,j-4)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-4)(0), arrFrame(i-1,j-4)(0), arrPtNormal)
arrCircle(2) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-6)(0), Rhino.VectorScale (arrFrame(i-1,j-6)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-6)(0), arrFrame(i-2,j-6)(0), arrPtNormal)
arrCircle(3) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-8)(0), Rhino.VectorScale (arrFrame(i,j-8)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-8)(0), arrFrame(i-1,j-8)(0), arrPtNormal)
arrCircle(4) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-10)(0), Rhino.VectorScale (arrFrame(i-1,j-10)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-10)(0), arrFrame(i-2,j-10)(0), arrPtNormal)
arrCircle(5) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-12)(0), Rhino.VectorScale (arrFrame(i,j-12)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-12)(0), arrFrame(i-1,j-12)(0), arrPtNormal)
arrCircle(6) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-14)(0), Rhino.VectorScale (arrFrame(i-1,j-14)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-14)(0), arrFrame(i-2,j-14)(0), arrPtNormal)
arrCircle(7) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-16)(0), Rhino.VectorScale (arrFrame(i,j-16)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-16)(0), arrFrame(i-1,j-16)(0), arrPtNormal)
arrCircle(8) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-18)(0), Rhino.VectorScale (arrFrame(i-1,j-18)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-18)(0), arrFrame(i-2,j-18)(0), arrPtNormal)
arrCircle(9) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-20)(0), Rhino.VectorScale (arrFrame(i,j-20)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-20)(0), arrFrame(i-1,j-20)(0), arrPtNormal)
arrCircle(10) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-22)(0), Rhino.VectorScale (arrFrame(i-1,j-22)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-22)(0), arrFrame(i-2,j-22)(0), arrPtNormal)
arrCircle(11) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-24)(0), Rhino.VectorScale (arrFrame(i,j-24)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-24)(0), arrFrame(i-1,j-24)(0), arrPtNormal)
arrCircle(12) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j)(0), Rhino.VectorScale (arrFrame(i-2,j)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j)(0), arrFrame(i-1,j)(0), arrPtNormal)
arrCircleb(0) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-2)(0), Rhino.VectorScale (arrFrame(i-1,j-2)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-2)(0), arrFrame(i,j-2)(0), arrPtNormal)
arrCircleb(1) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-4)(0), Rhino.VectorScale (arrFrame(i-2,j-4)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-4)(0), arrFrame(i-1,j-4)(0), arrPtNormal)
arrCircleb(2) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-6)(0), Rhino.VectorScale (arrFrame(i-1,j-6)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-6)(0), arrFrame(i,j-6)(0), arrPtNormal)
arrCircleb(3) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-8)(0), Rhino.VectorScale (arrFrame(i-2,j-8)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-8)(0), arrFrame(i-1,j-8)(0), arrPtNormal)
arrCircleb(4) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-10)(0), Rhino.VectorScale (arrFrame(i-1,j-10)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-10)(0), arrFrame(i,j-10)(0), arrPtNormal)
arrCircleb(5) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-12)(0), Rhino.VectorScale (arrFrame(i-2,j-12)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-12)(0), arrFrame(i-1,j-12)(0), arrPtNormal)
arrCircleb(6) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-14)(0), Rhino.VectorScale (arrFrame(i-1,j-14)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-14)(0), arrFrame(i,j-14)(0), arrPtNormal)
arrCircleb(7) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-16)(0), Rhino.VectorScale (arrFrame(i-2,j-16)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-16)(0), arrFrame(i-1,j-16)(0), arrPtNormal)
arrCircleb(8) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-18)(0), Rhino.VectorScale (arrFrame(i-1,j-18)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-18)(0), arrFrame(i,j-18)(0), arrPtNormal)
arrCircleb(9) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-20)(0), Rhino.VectorScale (arrFrame(i-2,j-20)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-20)(0), arrFrame(i-1,j-20)(0), arrPtNormal)
arrCircleb(10) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-22)(0), Rhino.VectorScale (arrFrame(i-1,j-22)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-22)(0), arrFrame(i,j-22)(0), arrPtNormal)
arrCircleb(11) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-24)(0), Rhino.VectorScale (arrFrame(i-2,j-24)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-24)(0), arrFrame(i-1,j-24)(0), arrPtNormal)
arrCircleb(12) = Rhino.AddCircle (arrPlane, dblRadius+k)

Call Rhino.AddLoftSrf (arrCircle)
Call Rhino.AddLoftSrf (arrCircleb)

‘strcrvb = rhino.AddInterpCurve (array(arrFrame(i-2,j)(0),_
‘    arrFrame(i-1,j-2)(0),_
‘    arrFrame(i-2,j-4)(0),_
‘    arrFrame(i-1,j-6)(0),_
‘    arrFrame(i-2,j-8)(0),_
‘    arrFrame(i-1,j-10)(0),_
‘    arrFrame(i-2,j-14)(0),_
‘    arrFrame(i-1,j-16)(0),_
‘    arrFrame(i-2,j-18)(0),_
‘    arrFrame(i-1,j-20)(0),_
‘    arrFrame(i-2,j-22)(0)))
End If
Next
Next
End Sub

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