Move depths into objects, add more bitting information

This commit is contained in:
Adam Goldsmith 2022-03-01 12:38:31 -05:00
parent 6f62c24f9b
commit a8f2382f5e
2 changed files with 62 additions and 19 deletions

View File

@ -1,3 +1,5 @@
from dataclasses import dataclass
MM_PER_IN = 25.4
@ -11,21 +13,61 @@ def depths_in_to_mm(depths):
return {name: depth * MM_PER_IN for name, depth in depths.items()}
@dataclass
class BittingSpecification:
key_thickness: float
root_cut: float
included_angle: float
positions: int
TFC: float # To First Cut (center)
BCC: float # Between Cut Centers
depths: dict[str, float]
# https://www.lockreference.com/wp-content/uploads/2019/03/Yale-Disc-Tumbler.pdf
yale_disc = depths_in_to_mm({
"1": .250,
"2": .230,
"X": .220, # also called "7"
"3": .210,
"4": .190,
"5": .170,
})
yale_disc = BittingSpecification(
key_thickness=0, # TODO
root_cut=.044 * MM_PER_IN,
included_angle=90,
positions=5,
TFC=.125 * MM_PER_IN,
BCC=.095 * MM_PER_IN,
depths=depths_in_to_mm({
"1": .250,
"2": .230,
"X": .220, # also called "7"
"3": .210,
"4": .190,
"5": .170,
}))
# https://www.lockreference.com/wp-content/uploads/2018/01/Yale-.019.pdf
yale_019 = depths_in_to_mm(linear_depths(0, 9, .320, .019))
yale_019 = BittingSpecification(
key_thickness=0, # TODO
root_cut=.054 * MM_PER_IN,
included_angle=95, # 110, 95, or 86
positions=7,
TFC=.200 * MM_PER_IN,
BCC=.165 * MM_PER_IN,
depths=depths_in_to_mm(linear_depths(0, 9, .320, .019)))
# https://www.lockreference.com/wp-content/uploads/2018/01/Yale-.025.pdf
yale_025 = depths_in_to_mm(linear_depths(0, 7, .320, .025))
yale_025 = BittingSpecification(
key_thickness=0, # TODO
root_cut=.054 * MM_PER_IN,
included_angle=95, # 110, 95, or 86
positions=7,
TFC=.200 * MM_PER_IN,
BCC=.165 * MM_PER_IN,
depths=depths_in_to_mm(linear_depths(0, 7, .320, .025)))
# https://www.lockreference.com/wp-content/uploads/2018/09/National-Disc-Tumbler-Single-Sided.pdf
national_disc_tumbler = depths_in_to_mm(linear_depths(1, 4, .250, .025))
national_disc_tumbler = BittingSpecification(
key_thickness=2,
root_cut=.044 * MM_PER_IN,
included_angle=90,
positions=6,
TFC=.156 * MM_PER_IN,
BCC=.093 * MM_PER_IN,
depths=depths_in_to_mm(linear_depths(1, 4, .250, .025)))

View File

@ -2,10 +2,11 @@ import cadquery as cq
from cadquery import exporters
import key_bittings
from key_bittings import BittingSpecification
MM_PER_IN = 25.4
key_thickness = 2 + .2
extra_key_thickness = 0.2
text_size = 4
text_depth = 0.5
@ -28,11 +29,11 @@ key_guide_width = 15
key_guide_height = 12.5
notch_width = 1
notch_height = 1.32
notch_height = 1.5
notch_depth = 0.5
def lishi_template(name, depth):
def lishi_template(spec: BittingSpecification, name: str, depth: float):
result = (
cq
.Workplane("front")
@ -60,12 +61,12 @@ def lishi_template(name, depth):
result
.faces(">Y", tag="lishi_interface").vertices(">X and <Z")
.workplane(centerOption="CenterOfMass")
.rect(key_guide_width, key_guide_height, centered=False).extrude(key_thickness + back_thickness, combine=False)
.rect(key_guide_width, key_guide_height, centered=False).extrude(spec.key_thickness + extra_key_thickness + back_thickness, combine=False)
.tag("key_guide")
.edges("not <Y").fillet(corner_radius)
.faces(">X", tag="key_guide").vertices("<Z and <Y").workplane(centerOption="CenterOfMass").center(0, bottom_thickness + lishi_cutter_offset - depth)
# ideally, the key profile would be passed in as an argument
.rect(key_thickness, depth, centered=False).cutThruAll()
.rect(spec.key_thickness + extra_key_thickness, depth, centered=False).cutThruAll()
.union(result) # this seems like a fairly bad way to do this, but it does work
)
@ -82,7 +83,7 @@ def lishi_template(name, depth):
return result
for name, depth in key_bittings.national_disc_tumbler.items():
#log(f"{name}, {depth}")
result = lishi_template(name, depth)
spec = key_bittings.national_disc_tumbler
for name, depth in spec.depths.items():
result = lishi_template(spec, name, depth)
exporters.export(result, f'national_disc_tumbler_{name}.stl')