lockpuzzle/case.scad

51 lines
No EOL
1.1 KiB
OpenSCAD

module case(n=5, diameter=50, tolerance=0.2, $fn=60) {
union() {
translate([-8,0,0]) {
rotate([0,90,0]) {
// outer cylinder
difference() {
cylinder(h=n*10+6, d=diameter-11);
translate([0,0,-1]) {
cylinder(h=n*10+8, d=diameter-17);
}
// key cutout
translate([-diameter/2+4,-1.5,-1]) {
cube([7,3,n*10+7]);
}
// cutouts for e-clips
rotate([0,0,45]) {
for (j = [0:2]) {
rotate([0,0,120*j]) {
for (i = [0:n]) {
translate([0,diameter/4,10*i+3]) {
cube([4+2*tolerance, diameter/2, 2+2*tolerance], center=true);
}
}
}
}
}
}
// end cap
translate([0,0,(n+1)*10-2.5]) {
cylinder(d=diameter,h=5, center=true);
}
}
}
}
}
// DEFAULTS FOR COMMAND LINE INVOCATION
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
N = 5;
DIAMETER = 50;
TOLERANCE = 0.2;
FN = 60;
case(
n=N,
diameter=DIAMETER,
tolerance=TOLERANCE, $fn=FN);