from openscad import *

# hinge not pip

length=40
width=20
sections=5
thick=2
pind=3
tol=.2

###################################################

fn=200
cross_sec= square([thick,width]).translate([tol,0,0])
cross_sec=union(cross_sec,circle(d=pind+thick+thick)).difference(circle(d=pind))
cross_sec.show()
leaf1=cross_sec.linear_extrude(length)
leaf2=leaf1
leaf2.show()
# total sections = 2*sections-1
sec_height=length/((2*sections)-1)
print(sec_height)

# cut out leaf including tolerance (sections-1) times

cut=cylinder (d=pind+thick+thick+tol,h=sec_height+tol)

for j in range(0,sections,1):
    leaf1=difference(leaf1,cut.translate([0,0,j*sec_height*2]))
    
leaf1.show()

for j in range(0,sections,1):
    leaf2=difference(leaf2,cut.translate([0,0,(j*sec_height*2)-sec_height-tol/2]))
  
leaf2.show()    

show(leaf1|leaf2.translate([width+5,0,0]))

