import rhinoscriptsyntax as rs
Srf = rs.GetObject("select Surface",8)
U = rs.SurfaceDomain(Srf,0)
V = rs.SurfaceDomain(Srf,1)
arrpts = {}
arrMidPts2 = {}
arrParam = [0,0]
nRows = rs.GetInteger("SubDivs in U?",20,5,100)
nColumns = rs.GetInteger("SubDivs in V?",20,5,100)
for m in range(0,nRows+1):
arrParam[0] = (U[0]+(((U[1]-U[0])/nRows)*m))
for n in range(0,nColumns+1):
arrParam[1] = (V[0]+(((V[1]-V[0])/nColumns)*n))
arrpts[(m,n)] = rs.EvaluateSurface(Srf,arrParam[0],arrParam[1])
arrMidPts = rs.EvaluateSurface(Srf,arrParam[0]+((U[1]-U[0])/nRows)/2,arrParam[1]+((V[1]-V[0])/nColumns)/2)
param = arrParam[0]+((U[1]-U[0])/nRows)/2,arrParam[1]+((V[1]-V[0])/nColumns)/2
arrSrfNor = rs.SurfaceNormal(Srf,param)
arrMidPts2[(m+1/2),(n+1/2)] = arrMidPts+arrSrfNor
for i in range(0,nRows):
for j in range(0,nColumns):
midPt = arrMidPts2[(i+1/2),(j+1/2)]
pt1,pt2,pt3,pt4 = arrpts[i,j],arrpts[i+1,j],arrpts[i+1,j+1],arrpts[i,j+1]
arrRiPts = [pt2,midPt,pt3]
arrRiCrv = rs.AddCurve(arrRiPts)
arrMidPts = [pt1,midPt,pt3]
arrMidCrv = rs.AddCurve(arrMidPts)
arrRiSrf = rs.AddLoftSrf([arrRiCrv,arrMidCrv])
rs.DeleteObjects([arrRiCrv,arrMidCrv])
rs.DeleteObject(Srf) |