Ghpython add recursive boxes

ghpython
grasshopper

#1

Hello,
Plz I need to add a box extruded from a recursive squares

I found a script on Gh website and i would like to modify the script so that it is converted to a 3d recursive boxes.

I am wondering if I can add a surface connecting these four points (P1,P2,P3,P4 ) and then extrude this surface by a distance equals to (dist). recursively

Kindly find attached the GH file
Thank u in advance

user_gh.gh (17.7 KB)

this is the script

import rhinoscriptsyntax as rs



def koch(v1,v2):
    
    
    dist = rs.Distance(v1,v2)
    p1 = v2 - v1
    p1 = rs.VectorUnitize(p1)
    p1 *= dist * dist1
    p1 += v1 
    
    p2 = v2 - v1
    
    cross =v2 - v1 
    cross = rs.VectorUnitize(cross)
    cross = rs.VectorRotate (cross, 90, [0,0,1])
    cross *= dist * h
    p2 = rs.VectorUnitize(p2)
    p2 *= dist * dist1
    p2 += v1 + cross
    
    p3 = v2 - v1
    p3 = rs.VectorUnitize(p3)
    p3 *= dist * dist2
    p3 += v1 + cross
    
    
    p4 = v2 - v1
    p4 = rs.VectorUnitize(p4)
    p4 *= dist * dist2
    p4 += v1 
    
    
    
    return [v1, p1, p2, p3, p4, v2]

def recursive (v1,v2,gens , linelist ):
    
    if (gens > 0):
        
        
        newPts = koch (v1 , v2)
        l = rs.AddPolyline ([newPts[0],newPts[1],newPts[2],newPts[3],newPts[4],newPts[5]])
        linelist.append(l)
        
        recursive(newPts[0],newPts[1], gens-1, linelist)
        recursive(newPts[1],newPts[2], gens-1, linelist)
        recursive(newPts[2],newPts[3], gens-1, linelist)
        recursive(newPts[3],newPts[4], gens-1, linelist)
        recursive(newPts[4],newPts[5], gens-1, linelist)
        
        return linelist

allLines =[]


a = recursive(pt1,pt2, gens, allLines)



#a = koch (pt1,pt2)


#a = pt1 + pt2

this is the final result i need

Thank you in advance