
Option Explicit
Call Main()
Sub Main()
‘variables
Dim strSrf
Dim arrDomU, arrDomV, arrPt
Dim dblParamU, dblParamV
Dim i, j, intDivU, intDivV
‘inputs
strSrf = Rhino.GetObject(”sel the surface”,8)
If isnull(strSrf) Then Exit Sub ‘in the case i want to scape the script
‘number of the divisions
intDivU = 7
intDivV = 7
‘arrays declaration
ReDim collect1(intDivU, intDivV)
‘catch the surface the min and max in both directions u, v
arrDomU = Rhino.SurfaceDomain(strSrf,0)
arrDomV = Rhino.SurfaceDomain(strSrf,1)
‘here we evaluate boths surfaces with the same loop
For i = 0 To intDivU
For j = 0 To intDivV
‘here we calculate the point for boths surfaces
dblParamU = arrDomU(0) + i * ((arrDomU(1) - arrDomU(0)) / intDivU)
dblParamV = arrDomV(0) + j * ((arrDomV(1) - arrDomV(0)) / intDivV)
‘here we “fix” the point on the surface, with this function we can get a lot info from the surface
arrPt = Rhino.SurfaceCurvature(strSrf, array(dblParamU, dblParamV))
Rhino.AddPoint arrPt(0)
collect1(i,j) = arrPt(0) ‘<- store inside of the array
Next
Next
‘here assign names for the points that i want to pass
Dim Npoint, Npoint2, Npoint3, Npoint4
‘this is the ubication for every point
Npoint = collect1(1, 1)
Npoint2 = collect1(1, 2)
Npoint3 = collect1(2, 2)
Npoint4 = collect1(2, 1)
‘you know that
For i = 0 To (intDivU - 1)
For j = 0 To (intDivV - 1) ‘<- for stay inside of the loop
’so here every point has his real position for the loop
Npoint = collect1(i, j)
Npoint2 = collect1(i, j + 1)
Npoint3 = collect1(i + 1, j + 1)
Npoint4 = collect1(i + 1, j)
Call MyFuncPoint(Npoint, Npoint2, Npoint3, Npoint4, strSrf)
Next
Next
Rhino.HideObject strSrf
End Sub
Function MyFuncPoint(a, b, c, d, surface)
Dim F, pointF
Dim arrRndPt, RndPt
Dim line1, line2, line3, line4, P1, P2, P3, P4
Dim Nline1, Nline2, Nline3, Nline4, arrpoint1, arrpoint2, arrpoint3, arrpoint4
Dim surface1, curve1, planar1, curve2, planar2
Dim cur, cur2, cur3, cur4, finalcur, finalcur2
F = Array((a(0) + c(0))/ 2, (a(1) + c(1))/ 2, (a(2) + c(2))/ 2)
pointF = rhino.addpoint(F)
line1 = Rhino.AddLine(a, b)
P1 = Rhino.CurveMidPoint(line1)
line2 = Rhino.AddLine(b, c)
P2 = Rhino.CurveMidPoint(line2)
line3 = Rhino.AddLine(c, d)
P3 = Rhino.CurveMidPoint(line3)
line4 = Rhino.AddLine(d, a)
P4 = Rhino.CurveMidPoint(line4)
Nline1 = Rhino.AddLine(P1, P2)
arrpoint1 = Rhino.DivideCurve (Nline1, 3, True)
Nline2 = Rhino.AddLine(P2, P3)
arrpoint2 = Rhino.DivideCurve (Nline2, 3, True)
Nline3 = Rhino.AddLine(P3, P4)
arrpoint3 = Rhino.DivideCurve (Nline3, 3, True)
Nline4 = Rhino.AddLine(P4, P1)
arrpoint4 = Rhino.DivideCurve (Nline4, 3, True)
cur = Rhino.AddCurve (array(a, arrpoint4(1), arrpoint3(2), d))
cur2 = Rhino.AddCurve (array(d, arrpoint3(1), arrpoint2(2), c))
cur3 = Rhino.AddCurve (array(c, arrpoint2(1), arrpoint1(2), b))
cur4 = Rhino.AddCurve (array(b, arrpoint1(1), arrpoint4(2), a))
finalcur = Rhino.JoinCurves(array(cur, cur2, cur3, cur4), True)
curve1 = Rhino.AddPolyline (array(a,b,c,a))
planar1 = Rhino.AddPlanarSrf (array(curve1))
curve2 = Rhino.AddPolyline (array(a,b,c,d,a))
Dim Distance1: Distance1 = Rhino.Distance(a,b)/3
Dim Hpoint: Hpoint = funcplane(planar1, Distance1)
Dim H: H = Rhino.AddPoint (Hpoint)
Dim Hpoint2: Hpoint2 = funcplane(planar1, Distance1/3)
Dim H2: H2 = Rhino.AddPoint (Hpoint2)
Dim Lpoint: Lpoint = funcplane(planar1, -Distance1/7)
Dim L: L = Rhino.AddPoint (Lpoint)
Dim planarCent: planarCent = Rhino.SurfaceAreaCentroid(planar1(0))
finalcur2 = Rhino.CopyObject(finalcur(0), planarCent(0), Lpoint)
Rhino.AddLoftSrf (array(finalcur(0),finalcur2))
Dim arrpatch: arrpatch = array(finalcur(0), H)
Rhino.UnselectAllObjects
Rhino.SelectObjects (arrpatch)
Rhino.Command (” _-Patch ” & ” _enter “)
Rhino.HideObject planar1(0)
Dim arrpatch2: arrpatch2 = array(finalcur2, H2)
Rhino.UnselectAllObjects
Rhino.SelectObjects (arrpatch2)
Rhino.Command (” _-Patch ” & ” _enter “)
End Function
Function funcplane(S, Distance)
Dim arrPlane, arrNormal, arrCent, arrParam, arrPt1
Dim strView, Surf, arrsrfdata
Surf = S(0)
strView = Rhino.CurrentView
Rhino.ViewCPlane strView, Rhino.WorldXYPlane
arrCent = Rhino.SurfaceAreaCentroid(Surf)
arrParam = Rhino.SurfaceClosestPoint(Surf,arrCent(0))
arrNormal = Rhino.SurfaceNormal(Surf,arrParam)
arrPlane = Rhino.PlaneFromNormal(arrCent(0),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