lockpuzzle/plug.scad

60 lines
1.3 KiB
OpenSCAD

module plug(n=5, diameter=50, xy_tolerance=0.2, z_tolerance=0.4, $fn=60) {
union() {
// key
translate([-10,-1.25,(diameter-19)/2]) {
difference() {
cube([10*n+6,2.5,6]);
// key cutouts
for (i = [0:n-1]) {
translate([i*10+6,-0.25, 3.5]) {
cube([8,3,4]);
}
}
}
}
translate([-8.5,0,0]) {
rotate([0,90,0]) {
// inner cylinder
difference() {
cylinder(h=10*n+4.5, d=diameter-17-2*xy_tolerance);
translate([0,0,-1]) {
cylinder(h=10*n+7, d=diameter-20);
}
}
// end cap
difference() {
translate([0,0,-1]) {
cylinder(d=diameter,h=5, center=true);
}
// case ring cutout
translate([0,0,-1]) {
difference() {
cylinder(h=4, d=diameter-10);
translate([0,0,-1]) {
cylinder(h=6, d=diameter-18);
}
}
}
}
}
}
}
}
// DEFAULTS FOR COMMAND LINE INVOCATION
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
N = 5;
DIAMETER = 50;
Z_TOLERANCE = 0.4;
XY_TOLERANCE = 0.2;
FN = 60;
plug(
n=N,
diameter=DIAMETER,
z_tolerance=Z_TOLERANCE,
xy_tolerance=XY_TOLERANCE,
$fn=FN);