lockpuzzle/case.scad

54 lines
No EOL
1.2 KiB
OpenSCAD

module case(n=5, diameter=50, z_tolerance=0.4, xy_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 rings
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*xy_tolerance, diameter/2, 2+2*z_tolerance], center=true);
}
}
}
}
}
}
// end cap
translate([0,0,(n+1)*10-3]) {
cylinder(d=diameter,h=5, center=true);
}
}
}
}
}
// DEFAULTS FOR COMMAND LINE INVOCATION
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
N = 5;
DIAMETER = 50;
Z_TOLERANCE = 0.4;
XY_TOLERANCE = 0.2;
FN = 60;
case(
n=N,
diameter=DIAMETER,
z_tolerance=Z_TOLERANCE,
xy_tolerance=XY_TOLERANCE,
$fn=FN);