From a8f2382f5edc5c6928eb4bb6a71a7ce90f775190 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 1 Mar 2022 12:38:31 -0500 Subject: [PATCH] Move depths into objects, add more bitting information --- key_bittings.py | 64 ++++++++++++++++++++++++++++++++++++-------- snap_on_templates.py | 17 ++++++------ 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/key_bittings.py b/key_bittings.py index f8b8373..e438c3f 100644 --- a/key_bittings.py +++ b/key_bittings.py @@ -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))) diff --git a/snap_on_templates.py b/snap_on_templates.py index 1450558..177aed1 100644 --- a/snap_on_templates.py +++ b/snap_on_templates.py @@ -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 X", tag="key_guide").vertices("