lockpuzzle/plug.scad

57 lines
1.2 KiB
OpenSCAD

module plug(n=5, diameter=50, tolerance=0.2, $fn=60) {
union() {
// key
translate([-10,-1.25,(diameter-19)/2]) {
difference() {
cube([10*n+6.5,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+5, d=diameter-17-2*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;
TOLERANCE = 0.2;
FN = 60;
plug(
n=N,
diameter=DIAMETER,
tolerance=TOLERANCE, $fn=FN);