home processing download documents tutorial python tutorial gallery source about
 Python Tutorials (back to the list of tutorials)

Panelization Examples

     Panelization Example8

The following is an example of taking 2 input surfaces and building geometries between those surfaces. To use two surfaces at the same time, you assign two different variables to those surfaces, take points out of each surfaces. Note that the code below would crash if the input file doesn't contain 2 surfaces.

surface9.3dm

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface9.3dm")
surfaces = IG.surfaces()

surfA = surfaces[0]
surfB = surfaces[1]

unum = 10
vnum = 10
uinc = 1.0/unum
vinc = 1.0/vnum
for i in range(unum) : 
    for j in range(vnum) : 
        ptA = surfA.pt( i*uinc, j*vinc )
        ptB = surfB.pt( i*uinc, j*vinc )
        ICurve(ptA, ptB).clr(1.0,0,0)

Then multiple points on each surface are sampled in the for-loop body and used to build more connections.

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface9.3dm")
surfaces = IG.surfaces()

surfA = surfaces[0]
surfB = surfaces[1]

unum = 10
vnum = 10
uinc = 1.0/unum
vinc = 1.0/vnum
for i in range(unum) : 
    for j in range(vnum) : 
        ptA11 = surfA.pt( i*uinc, j*vinc )
        ptA21 = surfA.pt( (i + 1)*uinc, j*vinc )
        ptA12 = surfA.pt( i*uinc, (j + 1)*vinc)
        ptA22 = surfA.pt( (i + 1)*uinc, (j + 1)*vinc )
        
        ptB11 = surfB.pt( i*uinc, j*vinc )
        ptB21 = surfB.pt( (i + 1)*uinc, j*vinc )
        ptB12 = surfB.pt( i*uinc, (j + 1)*vinc)
        ptB22 = surfB.pt( (i + 1)*uinc, (j + 1)*vinc )
        
        ICurve(ptA11, ptB11).clr(1.,0,0)
        ICurve(ptA11, ptB22).clr(0,0,0.5)
        ICurve(ptA12, ptB12).clr(1.0,0,1.0)
        ICurve(ptA12, ptB21).clr(0.5,0,0.5)
        ICurve(ptA21, ptB11).clr(0)
surfA.del()
surfB.del()

Then those lines are piped with cylinders and triangular panels are added on the both sides.

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface9.3dm")
surfaces = IG.surfaces()

surfA = surfaces[0]
surfB = surfaces[1]

unum = 10
vnum = 10
uinc = 1.0/unum
vinc = 1.0/vnum
for i in range(unum) : 
    for j in range(vnum) : 
        ptA11 = surfA.pt( i*uinc, j*vinc )
        ptA21 = surfA.pt( (i + 1)*uinc, j*vinc )
        ptA12 = surfA.pt( i*uinc, (j + 1)*vinc)
        ptA22 = surfA.pt( (i + 1)*uinc, (j + 1)*vinc )
        
        ptB11 = surfB.pt( i*uinc, j*vinc )
        ptB21 = surfB.pt( (i + 1)*uinc, j*vinc )
        ptB12 = surfB.pt( i*uinc, (j + 1)*vinc)
        ptB22 = surfB.pt( (i + 1)*uinc, (j + 1)*vinc )
        
        # triangular panels
        ISurface(ptA11,ptA21,ptA22).clr(i*uinc,j*vinc,0,0.5)
        ISurface(ptA22,ptA12,ptA11).clr(i*uinc,j*vinc,0,0.5)
        ISurface(ptB11,ptB21,ptB12).clr(0,i*uinc,j*vinc,0.5)
        ISurface(ptB21,ptB22,ptB12).clr(0,i*uinc,j*vinc,0.5)
        
        # frame of panels (square-piping with degree 1, closed)
        size = 0.2
        IG.squarePipe([ptA11,ptA21,ptA22],1,True,size).clr(.2)
        IG.squarePipe([ptA22,ptA12,ptA11],1,True,size).clr(0.2)
        IG.squarePipe([ptB11,ptB21,ptB12],1,True,size).clr(0.2)
        IG.squarePipe([ptB21,ptB22,ptB12],1,True,size).clr(0.2)
        
        # pipe between two surfaces
        radius = 0.1
        ICylinder(ptA11, ptB11, radius).clr(1.,0,0)
        ICylinder(ptA11, ptB22, radius).clr(0,0,0.5)
        ICylinder(ptA12, ptB12, radius).clr(1.0,0,1.0)
        ICylinder(ptA12, ptB21, radius).clr(0.5,0,0.5)
        ICylinder(ptA21, ptB11, radius).clr(0)
surfA.del()
surfB.del()


(back to the list of tutorials)

HOME
FOR PROCESSING
DOWNLOAD
DOCUMENTS
TUTORIALS (Java / Python)
GALLERY
SOURCE CODE(GitHub)
PRIVACY POLICY
ABOUT/CONTACT