Option Explicit
‘Script written by
‘Script copyrighted by
‘Script version 29 มกราคม 2551 17:59:35
Call Main()
Sub Main()
Dim strsurface, Udomain, Vdomain, Uparam, Vparam, arrpoint
Dim i, j, secu, secv
secu = 10
secv = 5
ReDim colec(secu, secv)
‘input
strsurface = Rhino.getobject (”sel the surface”, ![]()
If isnull(strsurface) Then Exit Sub ‘in case i want to scape the script
‘catch the surface the min and max in both direction u, v
Udomain = Rhino.SurfaceDomain(strsurface,0)
Vdomain = Rhino.SurfaceDomain(strsurface,1)
‘looping
For i = 0 To secu
For j = 0 To secv
‘here we calculate the point on the surface
Uparam = Udomain(0) + i * ((Udomain(1) - Udomain(0)) / secu-rnd)
Vparam = Vdomain(0) + j * ((Vdomain(1) - Udomain(0)) / secv)
‘here we fix the point on the curve
arrpoint = Rhino.EvaluateSurface(strsurface, array(Uparam, Vparam))
Rhino.AddPoint arrpoint
colec(i,j) = arrpoint
Next
Next
Dim newpoint, newpoint2, newpoint3, newpoint4
newpoint = colec(1,1)
newpoint2 = colec(1,2)
newpoint3 = colec(2,2)
newpoint4 = colec(2,1)
For i = 0 To secu - 1
For j = 0 To secv - 1
newpoint = colec(i,j)
newpoint2 = colec(i, j + 1)
newpoint3 = colec(i + 1, j + 1)
newpoint4 = colec(i + 1, j)
Call mifunction(newpoint, newpoint2, newpoint3, newpoint4)
Next
Next
Rhino.HideObject strsurface
End Sub
Function mifunction(a, b, c, d)
‘defining variables
Dim line1, F
Dim planarsrf1, distance1, distance2, HighPoint
Dim planarsrf2, HighPoint2
Dim pl1, pl2, pl3
Dim R
Dim S
R = 0.04
S = 0.06
line1 = Rhino.AddLine (a,c)
F = Rhino.CurveMidPoint(line1)
‘Rhino.AddPoint F
planarsrf1 = Rhino.AddSrfPt (array(a,d,c))
planarsrf2 = Rhino.AddSrfPt (array(a,b,c))
distance1 = -0.6
distance2 = 0.6
HighPoint = funcplane(planarsrf1, distance1, F)
Rhino.AddPoint HighPoint
HighPoint2 = funcplane(planarsrf2, distance2, b)
Dim cyl1: cyl1= Rhino.AddCylinder(a, HighPoint2, R)
Dim cyl2: cyl2= Rhino.AddCylinder(c, HighPoint2, R)
Dim cyl3: cyl3= Rhino.AddCylinder(a, HighPoint, R)
Dim cyl4: cyl4= Rhino.AddCylinder(c, HighPoint, R)
Dim cyl5: cyl5= Rhino.AddCylinder(a, d, R)
Dim cyl6: cyl6= Rhino.AddCylinder(d, c, R)
Dim cyl7: cyl7= Rhino.AddCylinder(d, HighPoint, R)
Dim cyl8: cyl8= Rhino.AddCylinder(b, HighPoint2, R)
Rhino.AddSphere a, S
Rhino.AddSphere d, S
Rhino.AddSphere c, S
Rhino.AddSphere HighPoint, S
Rhino.AddSphere HighPoint2, S
Rhino.AddSphere b, S
pl1 = Rhino.AddSrfPt(array(d, a, HighPoint))
pl2 =Rhino.AddSrfPt(array(d, c, HighPoint))
pl3 = Rhino.AddSrfPt(array(a, c, HighPoint2))
Dim AA: AA = funcplane(pl1, R, A)
Dim DD: DD = funcplane(pl1, R, D)
Dim HH1: HH1 = funcplane(pl1, R, HighPoint)
Dim plhigh1: plhigh1 = Rhino.AddSrfPt(array(AA, DD, HH1))
Dim CC: CC = funcplane(pl2, -R, C)
Dim DD2: DD2 = funcplane(pl2, -R, D)
Dim HH11: HH11 = funcplane(pl2, -R, HighPoint)
Dim plhigh2: plhigh2 = Rhino.AddSrfPt(array(DD2, CC, HH11))
Dim AA2: AA2 = funcplane(pl3, -R, A)
Dim CC2: CC2 = funcplane(pl3, -R, C)
Dim HH2: HH2 = funcplane(pl3, -R, HighPoint2)
Dim plhigh3: plhigh3 = Rhino.AddSrfPt(array(AA2, CC2, HH2))
Rhino.HideObject pl1
Rhino.HideObject pl2
Rhino.HideObject pl3
Rhino.HideObject planarsrf1
Rhino.HideObject planarsrf2
Rhino.HideObject line1
End Function
Function funcplane(S, Distance, A)
Dim arrPlane, arrNormal, arrCent, arrParam, arrPt1
Dim strView, Surf, arrsrfdata
Surf = S
strView = Rhino.CurrentView
Rhino.ViewCPlane strView, Rhino.WorldXYPlane
arrParam = Rhino.SurfaceClosestPoint(Surf,A)
arrNormal = Rhino.SurfaceNormal(Surf,arrParam)
arrPlane = Rhino.PlaneFromNormal(A,arrNormal)
Rhino.ViewCPlane strView, arrPlane
arrsrfdata = Rhino.SurfaceCurvature (Surf, arrParam)
arrPt1 = funcCPlanePoint(array(0,0,Distance))
funcPlane = arrPt1
strView = Rhino.CurrentView
Rhino.ViewCPlane strView, Rhino.WorldXYPlane
End Function
Function funcCPlanePoint(inPoint)
Dim arrPoint, arrPlane
funcCPlanePoint = vbNull
arrPoint = inPoint
If IsArray(arrPoint) Then
arrPlane = Rhino.ViewCPlane(Rhino.CurrentView)
funcCPlanePoint = Rhino.XformCPlaneToWorld(arrPoint, arrPlane)
End If
End Function


















