add key bitting cutting code, add picture, and update README

This commit is contained in:
Eric Van Albert
2017-06-09 22:09:55 -04:00
parent 11a9169d4f
commit 1018af7e93
4 changed files with 62 additions and 9 deletions

View File

@@ -1,2 +1,15 @@
# keygen
OpenSCAD tools for generating physical keys
Tools for generating physical keys.
![152698](doc/key.png "Key in OpenSCAD")
## How it Works
1. Get some nice pictures of the side and tip of your key.
I recommend a flatbed scanner.
2. Trace the key outline, warding, and embossing in Inkscape
3. Use the provided Inkscape plugin to convert the paths to OpenSCAD polygons.
4. Look up online the various parameters of your key, such as plug diameter,
cut depths and locations.
5. Use the provided OpenSCAD functions `key_code_to_heights`,
`key_blank` and `key_bitting` to generate a 3D model of your key.
6. Send the key to be 3D printed.

BIN
doc/key.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -129,4 +129,33 @@ module key_blank(outline_points,
key_emboss(emboss_right_adj, emboss_depth, false, thickness, emboss_right_paths);
key_emboss(emboss_left_adj, emboss_depth, true, thickness, emboss_left_paths);
}
}
function key_code_to_heights(code, depth_table) = [for(i=[0:len(code)-1]) depth_table[search(code[i], "0123456789")[0]]];
module key_bitting_cutter(flat, angle, tool_height) {
polygon([[-0.5 * flat, 0],
[0.5 * flat, 0],
[0.5 * flat + tan(0.5 * angle) * tool_height, tool_height],
[0.5 * flat - tan(0.5 * angle) * tool_height, tool_height]]);
}
module key_bitting(heights,
locations,
flat,
angle=100,
cutter_width=5,
cutter_height=5) {
// Rotate the cutting tool to the proper orientation
rotate(-90, [0, 0, 1]) rotate(90, [1, 0, 0])
// Union together a handful of trapezoids
// that comprise the cuts
union() {
for(i=[0:len(heights)-1]) {
// Move to the proper location and height
translate([locations[i], heights[i]])
linear_extrude(height=cutter_width, center=true)
key_bitting_cutter(flat, angle, cutter_height);
}
}
}

View File

@@ -1,11 +1,22 @@
use <keygen.scad>
include <sc4.gen.scad>
key_blank(outline_points,
warding_points,
outline_paths=outline_paths,
emboss_right_points=emboss_points,
emboss_right_paths=emboss_paths,
emboss_left_points=emboss_points,
emboss_left_paths=emboss_paths,
offset=-outline_points[187]);
bitting_code = "024689";
cut_locations = [for(i=[.231, .3872, .5434, .6996, .8558, 1.012]) i*25.4];
depth_table = [for(i=[0.335:-0.015:0.199]) i*25.4];
heights = key_code_to_heights(bitting_code, depth_table);
difference() {
key_blank(outline_points,
warding_points,
outline_paths=outline_paths,
emboss_right_points=emboss_points,
emboss_right_paths=emboss_paths,
emboss_left_points=emboss_points,
emboss_left_paths=emboss_paths,
offset=-outline_points[187],
plug_diameter=12.7);
key_bitting(heights, cut_locations, .7874);
}