// hinge2.cs pd = 3 //pin diameter l = 50 // hinge length w = 15 // hinge width d = 8 // diameter of pin tube t = 3 // thickness of blade nh = 3 // number of fixing holes dh = 4 // diameter of fixing holes np = 3 // number of pivots per blade tol = 1 // tolerance between parts //ps = 30 // parts seperation for set (1 pin, 2 blades) bev =2 // corner bevel /////////////////////////////////// // cylinder for pin tu= cylinder(h=l,d1=d,d2=d) // blade bl=cube([l,w,t]) // fixing holes hl = cylinder(h=3*t,d1=dh,d2=dh) spx= l/nh spy= (w+(d/2))/2 for j= spx/2 to l step spx hp= translate (hl,[j,spy,-t]) bl = difference([bl,hp]) next // position blade to tube bl=rotate (bl,[0,-90,0]) xm= (d/2)-t bl=translate(bl,[-xm,0,0]) bl= union([bl,tu]) // hole for pin hl= cylinder (h=3*l,d1=pd+tol,d2=pd+tol) hl= translate(hl,[0,0,-l]) bl=difference ([bl,hl]) // notch blade, ln = length of notch, d = d+tol // l= (np*2*pl) +(np-1)*tol) ... l/np= 2*(pl+ tol)-tol pl= (((l+tol)/np)-tol)/2 os= pl +pl +tol //offset for notch not= cylinder (h=pl+tol,d1=d+tol,d2=d+tol) for j= pl to l step os np =translate(not,[0,0,j]) print(j) bl= difference([bl,np]) next //pin pin =cylinder (h=l,d1=pd,d2=pd) wedge = cylinder (h= pl,d1=pd+tol,d2=pd) pin = union ([pin,wedge]) pin= rotate(pin,[-90,0,0]) pin= translate(pin,[d*2,0,pd/2.8] ) //flatten bottom of pin by difference dif0=cube([1000,1000,1000],center=true) dif = translate(dif0,[0,0,-500]) pin= difference([pin,dif]) // move blade to center and rotate 45deg bl=translate(bl,[0,-w/2,-l/2]) bl=rotate(bl,[-45,0,0]) // diag height dh= 0.707*(l+w) //diagonal height off= (dh/2)-bev // offset from bevel to centre // cut corners by intersect of translated cube cs=1000 inc=cube([cs,cs,cs],center=true) cd= cs/2 inc= translate(inc,[0,-cd+off,cd-off]) bl=intersect([bl,inc]) // arrange for print ps=off+d+5 bl=translate(bl,[0,0,off]) bl2 =translate(bl,[0,ps+(d/2),0]) show_obj([pin,bl,bl2],"printhinge2.obj")