boxespy/boxes/generators/printer.py

201 lines
6.0 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
2014-03-16 18:26:12 +01:00
# Copyright (C) 2013-2014 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 *
2016-08-17 15:07:41 +02:00
class Printer(Boxes):
"""Work in progress"""
webinterface = False
def __init__(self, r=250, h=400, d_c=100):
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.r = r
self.h = h
self.d_c = d_c
2013-11-06 19:30:26 +01:00
# idlers
self.D_i = 17.0
self.d_i = 5.0
2016-08-17 15:07:41 +02:00
self.w_i = 7.0 # includes washers
def mainPlate(self, nr):
r = self.r
2013-07-26 00:12:18 +02:00
t2 = 0.5 * self.thickness
if nr:
return
2016-08-17 15:07:41 +02:00
self.moveTo(r - 5, r, -90)
self.hole(0, 0, r - 80)
D_i2 = self.D_i / 2
w_i2 = self.w_i / 2
2016-08-17 15:07:41 +02:00
d_c2 = self.d_c / 2
for i in range(6):
self.ctx.save()
2016-08-17 15:07:41 +02:00
self.moveTo(0, 0, i * 60)
# winches
if i % 2:
2016-08-17 15:07:41 +02:00
self.fingerHolesAt(r - 80, (d_c2 + 20), 70, angle=0)
self.fingerHolesAt(r - 80, -(d_c2 + 20), 70, angle=0)
if i == 5:
self.fingerHolesAt(r - 70 + t2, -(d_c2 + 20 + t2), 40, angle=-90)
2013-07-26 00:12:18 +02:00
else:
2016-08-17 15:07:41 +02:00
self.fingerHolesAt(r - 70 + t2, (d_c2 + 20 + t2), 40, angle=90)
# idler buck
else:
2016-08-17 15:07:41 +02:00
d = 0.5 * (self.thickness) + w_i2
for y in (-d - d_c2, d - d_c2, -d + d_c2, d + d_c2):
self.fingerHolesAt(r - 30, y, 30, angle=0)
2016-08-17 15:07:41 +02:00
self.hole(r - 15 + D_i2, -self.d_c / 2, 0.4)
self.hole(r - 15 + D_i2, self.d_c / 2, 0.4)
self.ctx.restore()
def head(self):
d_c = self.d_c
2016-08-17 15:07:41 +02:00
self.moveTo(self.spacing + 10, self.spacing)
for i in range(3):
self.hole(0, 5, 0.3)
self.fingerHolesAt(25, 0, 20)
self.fingerHolesAt(75, 0, 20)
self.edge(d_c)
self.hole(0, 5, 0.3)
self.corner(120, 10)
2013-07-26 00:12:18 +02:00
def support(self, x, y, edges="ff", pair=False, callback=None, move=None):
if len(edges) != 2:
2014-03-03 21:45:01 +01:00
raise ValueError("Two edges required")
2016-08-17 15:07:41 +02:00
edges = [self.edges.get(e, e, ) for e in edges]
2013-07-26 00:12:18 +02:00
overallwidth = x + edges[0].spacing() + self.edges["e"].spacing()
overallheight = y + edges[1].spacing() + self.edges["e"].spacing()
2016-08-17 15:07:41 +02:00
r = 2 * self.thickness
2013-07-26 00:12:18 +02:00
if pair:
2016-08-17 15:07:41 +02:00
overallwidth += edges[0].spacing() + r - self.edges["e"].spacing()
overallheight += edges[1].spacing() + r - self.edges["e"].spacing()
2013-07-26 00:12:18 +02:00
if self.move(overallwidth, overallheight, move, before=True):
return
self.ctx.save()
self.moveTo(edges[0].margin(), edges[1].margin())
2016-08-17 15:07:41 +02:00
angle = math.degrees(math.atan((y - r) / float(x - r)))
2013-07-26 00:12:18 +02:00
self.cc(callback, 0)
edges[1](x)
self.corner(90)
2016-08-17 15:07:41 +02:00
# self.edge(self.thickness)
self.corner(90 - angle, r)
self.edge(((x - r) ** 2 + (y - r) ** 2) ** 0.5)
2013-07-26 00:12:18 +02:00
self.corner(angle, r)
2016-08-17 15:07:41 +02:00
# self.edge(self.thickness)
2013-07-26 00:12:18 +02:00
self.corner(90)
self.cc(callback, 0)
edges[0](y)
self.corner(90)
self.ctx.restore()
if pair:
self.ctx.save()
self.moveTo(overallwidth, overallheight, 180)
self.support(x, y, edges, False, callback)
self.ctx.restore()
self.move(overallwidth, overallheight, move)
def render(self):
self.open()
self.edges["f"].settings.setValues(self.thickness, surroundingspaces=0)
self.ctx.save()
2016-08-17 15:07:41 +02:00
for i in range(3):
# motor mounts
self.rectangularWall(70, 70, edges="feee", callback=[
2016-08-17 15:07:41 +02:00
lambda: self.NEMA(23, 35, 35), ],
move="right")
# winch bucks
2013-11-06 19:30:26 +01:00
self.rectangularWall(50, 70, edges="efee", callback=[
2016-08-17 15:07:41 +02:00
None,
lambda: self.hole(35, 35, 8.5),
None,
lambda: self.fingerHolesAt(10, 0, 50)], move="right")
2013-11-06 19:30:26 +01:00
self.support(40, 50, move="right", pair=True)
self.support(40, 50, move="right")
self.ctx.restore()
2013-11-06 19:30:26 +01:00
self.moveTo(0, 80)
self.ctx.save()
2016-08-17 15:07:41 +02:00
# idler bucks
for i in range(12):
self.rectangularWall(30, 30, edges="feee", callback=[
2016-08-17 15:07:41 +02:00
lambda: self.hole(15, 15, 3), ], move="right")
# Cable adjustment blocks
self.ctx.save()
2016-08-17 15:07:41 +02:00
for i in range(6):
def holes():
self.hole(5, 4, 1.5)
self.hole(15, 4, 1.5)
2016-08-17 15:07:41 +02:00
self.rectangularWall(20, 8, edges="feee", callback=[holes, ],
move="right")
self.ctx.restore()
self.moveTo(0, 20)
2016-08-17 15:07:41 +02:00
# Cable adjustment glyders
for i in range(6):
self.rectangularWall(8, 10, move="right", callback=[
2016-08-17 15:07:41 +02:00
lambda: self.hole(4, 4, 1.5),
None,
lambda: self.hole(4, 1.5, 0.4)])
self.rectangularWall(8, 10, move="right", callback=[
2016-08-17 15:07:41 +02:00
lambda: self.nutHole("M3", 4, 4),
None,
lambda: self.hole(4, 1.5, 0.4)])
self.ctx.restore()
self.moveTo(0, 40)
# mainPlate
2016-08-17 15:07:41 +02:00
self.rectangularWall(2 * self.r - 10, 2 * self.r - 10, edges="ffff",
callback=self.mainPlate, move="right")
2016-08-17 15:07:41 +02:00
self.head()
2014-03-21 21:08:54 +01:00
self.close()
2016-08-17 15:07:41 +02:00
2016-03-23 22:05:06 +01:00
def main():
p = Printer()
p.parseArgs()
p.render()
2016-08-17 15:07:41 +02:00
2016-03-23 22:05:06 +01:00
if __name__ == '__main__':
main()