$fn = 32; $space = 3; $width = 15.5; $length = $width; $height = 1; $holes = $height*4; $cut = $holes/2*-1; $clearance = 0.2; $switchDistance = $width+ $space; $shellWidth = 6; $shellHeight = 3.5 + $clearance; $magnetWidth = 4; $magnetHeight = 2; $columns = 6; $rows = 5; $fingerStep = 5; $xBase = (($width + $space) * $columns) + $space; $yBase = (($length + $space) * $rows) + $space; module pin(){ cylinder(h=$holes, r=1, center=false); } module switch($diodesTop = false){ $xCenter = $width/2; $yCenter = $length/2; translate([$xCenter, $yCenter, 0]) cylinder(h=$holes, r=2.522, center=false); translate([$xCenter + 0, $yCenter + 5.9,0]) pin(); translate([$xCenter + 5, $yCenter + 3.8,0]) pin(); translate([$xCenter + -5, $yCenter + 3.8,0]) pin(); translate([$xCenter + -5, $yCenter + -5.15,0]) pin(); translate([$xCenter + 5, $yCenter+-5.15,0]) pin(); translate([0, $length + 1.4, 0]); $dDistanceFromCenter = $switchDistance/2; $dWidth = 10.95; $dHeight = 1.8; if ($diodesTop){ translate([$xCenter - ($dWidth/2), $yCenter + $dDistanceFromCenter - ($dHeight/2), 0]){ cube([$dWidth, $dHeight, $holes]); } } } module switchColumn(){ difference() { translate([-($space/2), -($space/2)]) cube([$switchDistance, $switchDistance * $rows, $height]); for (y=[0:$rows-1]){ translate([0 * ($width + $space) ,y * ($length+$space) ,0]) { switch(y<3); } } } } module rightTopDampener(){ union(){ switchColumn(); translate([$switchDistance,0,0]) switchColumn(); translate([$switchDistance * 2,5,0]) switchColumn(); translate([$switchDistance * 3,0,0]) switchColumn(); translate([$switchDistance * 4,-5,0]) switchColumn(); translate([$switchDistance * 5,-5,0]) switchColumn(); } } module leftTopDampener(){ rotate([0,180,0]){ rightTopDampener(); } } module topDampeners(){ translate([10,0,0]){ rightTopDampener(); } translate([-10,0,0]){ leftTopDampener(); } } module case(){ module magnets(){ cylinder(h=$magnetHeight + $clearance, r=$magnetWidth + $clearance / 2); } points = [ [0,0], [0, $switchDistance * $rows], [$switchDistance * 2, $switchDistance * $rows], [$switchDistance * 2, $switchDistance * $rows + $fingerStep], [$switchDistance * 3, $switchDistance * $rows + $fingerStep], [$switchDistance * 3, $switchDistance * $rows], [$switchDistance * 4, $switchDistance * $rows], [$switchDistance * 4, $switchDistance * $rows - $fingerStep], [$switchDistance * 6, $switchDistance * $rows - $fingerStep], [$switchDistance * 6, 0 - $fingerStep], [$switchDistance * 4, 0 - $fingerStep], [$switchDistance * 4, 0], [$switchDistance * 3, 0], [$switchDistance * 3, 0 + $fingerStep], [$switchDistance * 2, 0 + $fingerStep], [$switchDistance * 2, 0], ]; difference(){ union() { linear_extrude($shellHeight){ difference(){ offset(r=$shellWidth/2 + $clearance, chamfer=true) polygon(points); offset(r=$clearance) polygon(points); } } translate([0,0,-3]){ linear_extrude(3){ offset(r=$shellWidth/2 + $clearance, chamfer=true) polygon(points); } } } rotate([90,0,0]) { translate([0,0,-500]){ linear_extrude(99999){ polygon( [ [0 - $shellWidth/2, -3], [$switchDistance * 6 + $switchDistance/2,0], [$switchDistance * 6 + $shellWidth/2, -3] ] ); } } } // usb translate([10, $switchDistance * 5, -2]){ union() { cube([10,$shellWidth,5]); translate([-5,-$shellWidth + $clearance - 40,0]) cube([20,$shellWidth + 40,5]); } } // aux translate([-$shellWidth,75,0]) rotate([0,90,0]) cylinder(h=$shellWidth + 15,r=2.5); translate([0,0,5]) magnets(); } } //topDampeners(); case();