Tuesday, April 24, 2012

Hexagonal Paneling on NURBS Surface





import rhinoscriptsyntax as rs

rs.EnableRedraw(False)
srf=rs.GetObject("select surface")
ud=rs.SurfaceDomain(srf,0)
vd=rs.SurfaceDomain(srf,1)


lenu=ud[1]-ud[0]
lenv=vd[1]-vd[0]
rlist=[]

#print ud
#print lenu
#print vd
#print lenv

for i in rs.frange(ud[0],ud[1]+(lenu/20),lenu/20):
    clist=[]
    for j in rs.frange(vd[0],vd[1],lenv/20):
        clist.append(rs.EvaluateSurface(srf,i,j))
    rlist.append(clist)
for i in range(0,len(rlist)):
    for j in range(0,len(rlist[i])):
        rs.AddPoint(rlist[i][j])
pline=[]
for i in range(0,(len(rlist)-1),2):
    for j in range(1,(len(rlist[i])-1),4):
        p=[rlist[i+1][j+0],rlist[i+2][j+1],rlist[i+2][j+2],rlist[i+1][j+3],rlist[i+0][j+2],rlist[i+0][j+1],rlist[i+1][j+0]]
        pline.append(rs.AddPolyline(p))

pline2=[]
for i in range(1,(len(rlist)-2),2):
    for j in range(3,(len(rlist[i])-2),4):
        p=[rlist[i+1][j+0],rlist[i+2][j+1],rlist[i+2][j+2],rlist[i+1][j+3],rlist[i+0][j+2],rlist[i+0][j+1],rlist[i+1][j+0]]
        pline2.append(rs.AddPolyline(p))

No comments:

Post a Comment