From 6dff8db710ea32a2e9a68ed749756b89c366c20a Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 13 Oct 2020 16:07:31 +0200 Subject: [PATCH] Add alignment pins to BayonetBox Also add a lower ring to the bayonet lid of the RegularBox limiting rotation --- boxes/generators/bayonetbox.py | 28 +++++++++++++++++++++++++--- boxes/generators/regularbox.py | 6 +++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/boxes/generators/bayonetbox.py b/boxes/generators/bayonetbox.py index 6f2b674..c14e214 100644 --- a/boxes/generators/bayonetbox.py +++ b/boxes/generators/bayonetbox.py @@ -31,8 +31,27 @@ class BayonetBox(Boxes): self.argparser.add_argument( "--lugs", action="store", type=int, default=10, help="number of locking lugs") + self.argparser.add_argument( + "--alignment_pins", action="store", type=float, default=1.0, + help="diameter of the alignment pins") self.buildArgParser("outside") + def alignmentHoles(self, inner=False, outer=False): + d = self.diameter + r = d / 2 + t = self.thickness + p = 0.05*t + l = self.lugs + + a = 180 / l + with self.saved_context(): + for i in range(3): + if outer: + self.hole(r-t/2, 0, d=self.alignment_pins) + if inner: + self.hole(r-2*t-p, 0, d=self.alignment_pins) + self.moveTo(0, 0, 360/3) + def lowerLayer(self, asPart=False, move=None): d = self.diameter r = d / 2 @@ -47,6 +66,7 @@ class BayonetBox(Boxes): return self.moveTo(d/2, d/2) + self.alignmentHoles(inner=True) self.hole(0, 0, r=d/2 - 2.5*t) self.moveTo(d/2 - 1.5*t, 0, -90) @@ -65,6 +85,7 @@ class BayonetBox(Boxes): a = 180 / l + self.alignmentHoles(outer=True) with self.saved_context(): self.lowerLayer() @@ -84,6 +105,7 @@ class BayonetBox(Boxes): self.hole(0, 0, r=d/2 - 2.5*t) self.hole(0, 0, r=d/2 - 1.5*t) + self.alignmentHoles(inner=True, outer=True) self.moveTo(d/2 - 1.5*t, 0, -90) for i in range(l): @@ -99,8 +121,8 @@ class BayonetBox(Boxes): self.diameter = d = d - 3*t - self.parts.disc(d, move="right") - self.parts.disc(d, callback=lambda: self.hole(0, 0, d/2-1.5*t), move="right") + self.parts.disc(d, callback=lambda: self.alignmentHoles(outer=True), move="right") + self.parts.disc(d, callback=lambda: (self.alignmentHoles(outer=True), self.hole(0, 0, d/2-1.5*t)), move="right") self.parts.disc(d, callback=self.lowerCB, move="right") self.parts.disc(d, callback=self.upperCB, move="right") - self.parts.disc(d, move="right") + self.parts.disc(d, callback=lambda : self.alignmentHoles(inner=True),move="right") diff --git a/boxes/generators/regularbox.py b/boxes/generators/regularbox.py index 53504c4..01b4d09 100644 --- a/boxes/generators/regularbox.py +++ b/boxes/generators/regularbox.py @@ -37,6 +37,9 @@ class RegularBox(BayonetBox): "--top", action="store", type=str, default="none", choices=["none", "hole", "angled hole", "angled lid", "angled lid2", "round lid", "bayonet mount"], help="style of the top and lid") + self.argparser.add_argument( + "--alignment_pins", action="store", type=float, default=1.0, + help="diameter of the alignment pins for bayonet lid") self.lugs=6 @@ -79,7 +82,8 @@ class RegularBox(BayonetBox): self.parts.disc(sh*2, move="right") if self.top == "bayonet mount": self.diameter = 2*sh - self.lowerLayer(asPart=True, move="right") + self.parts.disc(sh*2-0.1*t, callback=self.lowerCB, + move="right") self.regularPolygonWall(corners=n, r=r, edges='F', callback=[self.upperCB], move="right") self.parts.disc(sh*2, move="right")