Creating copies of keys using a 3d printer and OpenSCAD
The key model generator for OpenSCAD
x-openscad - 4.46 kB - 10/10/2017 at 05:24
My printer is a Flashforge Creator Pro, using ABS plastic. I used .15mm layer heights, and the print only took a couple minutes.
I use the "ABS Slurry" technique to get my prints to stick without a raft or brim. ABS plastic dissolves in acetone, and you can lay down a thinner-than-paper layer of it on glass printing beds by letting solution evaporate. It really works great for me.
The key looks and feels really nice.
Next to the real one, the dimensions look almost perfect! They're offset for comparison in the image, but they're really identical!
This is after 4 or 5 iterations of printing and gently trying it in locks. I even broke off one key deep in the lock and had to disassemble it. Luckily, with this kind of lock a few minutes of disassembly gets you down to the tumbler and housing. Unfortunately, I didn't think to take photos of inside the lock. I still couldn't remove the key so I had no choice but to remove the cylinder, exposing the tumblers, springs, etc.
In an exciting coincidence, a magic marker is just the right size to poke out the inner cylinder of the lock, but keep all the spring and pin nonsense in place. I did mange to spill the lower part of the tumbler pins, the ones that rotate with the key.
Fortunately, this level of teardown granted me enough access to extract the broken plastic key. As for the disorganized tumbler pins, inserting the correct key into lock and finding which pins laid flush with the outside of the cylinder was a no brainer. Put the lock back together, put the handle back in the door, no problem!
Luckily, this fail is not associated with the images above - the key pictured was a later attempt that was successful! The key opened and closed my lock once, was carefully removed in-tact, and placed on the victory shelf.
So, the verdict is - Yes! You can 3D print working copies of real keys. I suspect a new, tight lock might not work as well - mine is worn and it certainly helped.
If anyone wants the OpenSCAD source files, you can find them in the project's files. As you can see in the previous entry's screenshot, the code defines a key() function that generates the model. It takes a single parameter - a list of the 5 tooth heights, values 0 through 6.
Actually, it takes other values too, that change the geometry and dimensions of the key, a la parametric design. With more options implemented, it's possible to expand this code to generate models of other key types. However, at present, you can really only change the size of the handle or add length to the key you don't need anyway. But hey, that's a project for another rainy day.
Until now, I had been using SketchUp and manually editing a key model. Obviously, it wasn't precise enough so I decide to give OpenSCAD a shot. OpenSCAD is a programming environment where the code deals with manipulating 3d models. It can export .STLs, which is perfect for almost all 3d printing software.
A bit of programming later and, voila!:
An OpenSCAD program that generates models of Kwikset KW1 keys. It defines a function that, given the positions of the 5 teeth of the key, output a model. The models should be accurate - I found a decent tech spec here (PDF).
Next thing to do was import the model into my 3d printing software - I use Simplify3D - and prepare it for printing! Notice that I scaled the model by 2540% - OpenSCAD is unitless, meaning you "just" use numbers and worry about scaling it in whereever you send the model. Well, most 3D printing software assumes millimeters, but I like Imperial inches. One inch is 2.54cm, so we get that 2.54x scale factor.
A few months ago, I tried creating copies of my home keys in SketchUp. With a few iterations and eyeballing it, I eventually got something that slide in and out of the lock with ease:
It slid in and out of the lock pretty smooth, so I upgraded, added teeth with my same low-precision modeling technique, and iterated:
(There's actually debris for newer failures here too). The key made it into the lock, but was difficult to remove - a desperate yank with pliers did it. The lock stayed locked, so this was deemed a failure...so far.