From 056f6bb085e6ae6521c4e63e24b200d7a1e7a942 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 9 Jul 2024 22:30:29 -0700 Subject: [PATCH] feat: Gap in bayonet mount --- nhf/parts/handle.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nhf/parts/handle.py b/nhf/parts/handle.py index dc6a01f..d6b926c 100644 --- a/nhf/parts/handle.py +++ b/nhf/parts/handle.py @@ -73,6 +73,8 @@ class BayonetMount(Mount): # Angular span (in degrees) of the slider pin_span: float = 15 pin_height: float = 5 + # Wall at the bottom of the slot + gap: float = 3 # Angular span (in degrees) of the slot slot_span: float = 90 @@ -80,6 +82,7 @@ class BayonetMount(Mount): # Number of pins equally distributed along a circle n_pin: int = 2 + def __post_init__(self): assert self.diam_outer > self.diam_inner assert self.n_pin * self.slot_span < 360 @@ -91,7 +94,7 @@ class BayonetMount(Mount): return self.diam_inner def external_thread(self, length: float): - assert length > self.pin_height + assert length > self.pin_height + self.gap pin = ( Cq.Workplane('XY') .cylinder( @@ -109,17 +112,18 @@ class BayonetMount(Mount): ) result = ( Cq.Workplane('XY') + .workplane(offset=self.gap) .polarArray(radius=0, startAngle=0, angle=360, count=self.n_pin) .eachpoint(lambda loc: pin.located(loc), combine='a') .clean() ) return result def internal_thread(self, length: float): - assert length > self.pin_height + assert length > self.pin_height + self.gap slot = ( Cq.Workplane('XY') .cylinder( - height=length, + height=length - self.gap, radius=self.diam_outer / 2, angle=self.pin_span, centered=(True, True, False) @@ -140,7 +144,9 @@ class BayonetMount(Mount): radius=self.diam_outer / 2, centered=(True, True, False), ) - .polarArray(radius=0, startAngle=-self.slot_span+self.pin_span, angle=360, count=self.n_pin) + .copyWorkplane(Cq.Workplane('XY')) + .workplane(offset=self.gap) + .polarArray(radius=0, startAngle=self.slot_span, angle=360, count=self.n_pin) .cutEach(lambda loc: slot.located(loc)) .clean() .copyWorkplane(Cq.Workplane('XY'))