Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings for bed bolts #625

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion boxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions boxes/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
14 changes: 10 additions & 4 deletions boxes/generators/closedbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
Loading