From 0fa97e2f826fbf9a4b7215721dfeba50e9371052 Mon Sep 17 00:00:00 2001 From: chrysn Date: Sat, 10 Feb 2024 23:07:40 +0100 Subject: [PATCH 1/2] Add settings for bed bolts --- boxes/__init__.py | 5 ++++- boxes/edges.py | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index f5bdf7bd8..b7844ff09 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -389,7 +389,6 @@ def open(self): if self.ctx is not None: return - self.bedBoltSettings = (3, 5.5, 2, 20, 15) # d, d_nut, h_nut, l, l1 self.surface, self.ctx = self.formats.getSurface(self.format, self.output) if self.format == 'svg_Ponoko': @@ -644,6 +643,10 @@ def _buildObjects(self): **self.edgesettings.get("Lid", {})) self.lid = lids.Lid(self, self.lidSettings) + # Bed Bolts + bedbolt_settings = self.edgesettings.get("BedBolt") or edges.BedBoltSettings.absolute_params + self.bedBoltSettings = edges.BedBoltSettings.convert_settings_to_tuple(bedbolt_settings) + # Nuts self.addPart(NutHole(self, None)) # Gears diff --git a/boxes/edges.py b/boxes/edges.py index f2eb92ede..82359f3fd 100644 --- a/boxes/edges.py +++ b/boxes/edges.py @@ -2657,3 +2657,29 @@ def __call__(self, length, **kw): def margin(self) -> float: return self.settings.height + self.extra_height * self.settings.thickness + + +class BedBoltSettings(Settings): + """Settings for bed bolts +Values: + +* absolute_params + + * d : : Bore and slit diameter [mm] (eg. 4.0 for M4) + * d_nut : : Width of the nut [mm] (eg. 7.0 for M4) + * h_nut : : Height of the nut [mm] (not standardized, roughly 2.4 for M4) + * l : : Total slit length of the nut [mm] (eg. 17.0 for an M? x 20, accounting for 4mm thickness and giving 1mm tolerance) + * l1 : : Distance from the cut edge to the close edge of the nut [mm] +""" + + absolute_params = { + "d": 3.0, + "d_nut": 5.5, + "h_nut": 2.0, + "l": 20.0, + "l1": 15.0, + } + + @classmethod + def convert_settings_to_tuple(cls, args): + return (args['d'], args['d_nut'], args['h_nut'], args['l'], args['l1']) From 1288b445f8a25d3af0efd4cc529ea1ae0bfadfc6 Mon Sep 17 00:00:00 2001 From: chrysn Date: Sat, 10 Feb 2024 23:13:15 +0100 Subject: [PATCH 2/2] closedbox: Add option to enable bed bolts --- boxes/generators/closedbox.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/boxes/generators/closedbox.py b/boxes/generators/closedbox.py index 49c857441..ced689b0d 100644 --- a/boxes/generators/closedbox.py +++ b/boxes/generators/closedbox.py @@ -30,8 +30,13 @@ class ClosedBox(Boxes): def __init__(self) -> None: Boxes.__init__(self) self.addSettingsArgs(edges.FingerJointSettings) + self.addSettingsArgs(edges.BedBoltSettings) self.buildArgParser("x", "y", "h", "outside") + self.argparser.add_argument( + "--bedbolts", action="store", type=boolarg, default=False, + help="Use bed bolts") + def render(self): x, y, h = self.x, self.y, self.h @@ -43,10 +48,11 @@ def render(self): t = self.thickness - d2 = edges.Bolts(2) - d3 = edges.Bolts(3) - - d2 = d3 = None + if self.bedbolts: + d2 = edges.Bolts(2) + d3 = edges.Bolts(3) + else: + d2 = d3 = None self.rectangularWall(x, h, "FFFF", bedBolts=[d2] * 4, move="right", label="Wall 1") self.rectangularWall(y, h, "FfFf", bedBolts=[d3, d2, d3, d2], move="up", label="Wall 2")