New generators: Spool and FilamentSpool

This commit is contained in:
Florian Festi 2023-01-24 22:42:46 +01:00
parent 877a129b03
commit 05056e569b
9 changed files with 200 additions and 0 deletions

View File

@ -0,0 +1,98 @@
#!/usr/bin/env python3
# Copyright (C) 2013-2016 Florian Festi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import *
from boxes.generators.bayonetbox import BayonetBox
class FilamentSpool(BayonetBox):
"""A two part spool for 3D printing filament"""
description = """
Use small nails to properly align the pieces of the bayonet latch. Glue the parts of the bayonet latch before assembling the "axle". The inner parts go at the side and the outer parts at the inside of the axle.
![opened spool](static/samples/FilamentSpool-2.jpg)"""
ui_group = "Misc"
def __init__(self) -> None:
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.buildArgParser(h=48)
self.argparser.add_argument(
"--outer_diameter", action="store", type=float, default=200.0,
help="diameter of the flanges")
self.argparser.add_argument(
"--inner_diameter", action="store", type=float, default=100.0,
help="diameter of the center part")
self.argparser.add_argument(
"--axle_diameter", action="store", type=float, default=50.0,
help="diameter of the axle hole")
self.argparser.add_argument(
"--sides", action="store", type=int, default=8,
help="number of pieces for the center part")
self.argparser.add_argument(
"--alignment_pins", action="store", type=float, default=1.0,
help="diameter of the alignment pins")
def leftsideCB(self):
self.hole(0, 0, d=self.axle_diameter)
r, h, side = self.regularPolygon(self.sides, radius=self.inner_diameter/2)
for i in range(self.sides):
self.fingerHolesAt(-side/2, h+0.5*self.thickness, side, 0)
self.moveTo(0, 0, 360/self.sides)
self.outerHolesCB()
def outerHolesCB(self):
t = self.thickness
for i in range(6):
for j in range(2):
self.rectangularHole(
0, self.outer_diameter / 2 - 7.0,
self.outer_diameter * math.pi / 360 * 8, 5, r=2.5)
self.moveTo(0, 0, 10)
self.moveTo(0, 0, 360 / 6 - 20)
self.rectangularHole(
(self.outer_diameter + self.inner_diameter) / 4, 0,
(self.outer_diameter - self.inner_diameter) / 2 - 4*t, t, r=t/2)
def render(self):
t = self.thickness
self.inner_diameter -= 2 * t
r, h, side = self.regularPolygon(self.sides, radius=self.inner_diameter/2)
self.diameter = 2*h
self.lugs = self.sides
self.parts.disc(
self.outer_diameter, callback=self.leftsideCB, move="right")
self.parts.disc(
self.outer_diameter, hole=self.axle_diameter,
callback=lambda:(self.alignmentHoles(True),
self.outerHolesCB()),
move="right")
self.regularPolygonWall(
self.sides, r=self.inner_diameter/2, edges="f",
callback=[self.upperCB], move="right")
self.parts.disc(self.diameter, callback=self.lowerCB, move="right")
for i in range(self.sides):
self.rectangularWall(
side, self.h - t, "feFe",
callback=[lambda:self.hole(side/2, self.h-2*t, r=t)],
move="right")

99
boxes/generators/spool.py Normal file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env python3
# Copyright (C) 2013-2016 Florian Festi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import *
class Spool(Boxes):
"""A simple spool"""
ui_group = "Misc"
def __init__(self) -> None:
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.buildArgParser(h=100)
self.argparser.add_argument(
"--outer_diameter", action="store", type=float, default=200.0,
help="diameter of the flanges")
self.argparser.add_argument(
"--inner_diameter", action="store", type=float, default=80.0,
help="diameter of the center part")
self.argparser.add_argument(
"--axle_diameter", action="store", type=float, default=40.0,
help="diameter of the axle hole (axle not part of drawing)")
self.argparser.add_argument(
"--sides", action="store", type=int, default=8,
help="number of pieces for the center part")
self.argparser.add_argument(
"--reinforcements", action="store", type=int, default=8,
help="number of reinforcement ribs per side")
self.argparser.add_argument(
"--reinforcement_height", action="store", type=float, default=0.0,
help="height of reinforcement ribs on the flanges")
def sideCB(self):
self.hole(0, 0, d=self.axle_diameter)
r, h, side = self.regularPolygon(self.sides, radius=self.inner_diameter/2)
t = self.thickness
for i in range(self.sides):
self.fingerHolesAt(-side/2, h+0.5*self.thickness, side, 0)
self.moveTo(0, 0, 360 / self.sides)
if self.reinforcement_height:
for i in range(self.reinforcements):
self.fingerHolesAt(
self.axle_diameter / 2, 0, h-self.axle_diameter / 2, 0)
self.fingerHolesAt(
r + t, 0, self.outer_diameter / 2 - r - t, 0)
self.moveTo(0, 0, 360 / self.reinforcements)
def reinforcementCB(self):
for i in range(self.reinforcements):
self.fingerHolesAt(
self.axle_diameter / 2, 0,
(self.inner_diameter - self.axle_diameter) / 2 + self.thickness, 0)
self.moveTo(0, 0, 360 / self.reinforcements)
def render(self):
t = self.thickness
r, h, side = self.regularPolygon(self.sides, radius=self.inner_diameter/2)
for i in range(2):
self.parts.disc(
self.outer_diameter, callback=self.sideCB, move="right")
for i in range(self.sides):
self.rectangularWall(side, self.h, "fefe", move="right")
if self.reinforcement_height:
for i in range(self.reinforcements*2):
edge = edges.CompoundEdge(
self, "fef",
[self.outer_diameter / 2 - r - t,
r - h + t,
h - self.axle_diameter / 2])
self.trapezoidWall(
self.reinforcement_height - t,
(self.outer_diameter - self.axle_diameter) / 2,
(self.inner_diameter - self.axle_diameter) / 2 + t,
["e", "f", "e", edge],
move="right")
for i in range(2):
self.parts.disc(
self.inner_diameter + 2*t,
hole=self.axle_diameter,
callback=self.reinforcementCB,
move="right")

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
static/samples/Spool.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -111,3 +111,6 @@ b4b0aeecfd34eedb1a1e0b9763e219b77f4d0cea0ae39c5197e22dbae5d4f0d4 ../static/samp
f342316e00a07329aec8a9377274db4709870511126a3cada10ae9057f3f5367 ../static/samples/BirdHouse.jpg
7046e8171d15e3a01685ab0763fa8b4cbdecf98956c02203343579cab39b9c6f ../static/samples/SmallPartsTray2.jpg
bb294909eb5e7a1a49cc7d5ba72b08ca0baf42dd2302494aa1932432817ce973 ../static/samples/RollHolder.jpg
a7ee83b42685295fd02db666841984c55af2f9632540c651f5dea42088a3c170 ../static/samples/FilamentSpool.jpg
0524ca976f76c181135044b185eb4e6cf2ce92ab3316f48a6bc61b9366daefd1 ../static/samples/FilamentSpool-2.jpg
ab47e02fb9736d20b457964aa640f50852ac97bb2857cea753fa4c3067a60d41 ../static/samples/Spool.jpg