boxespy/boxes/generators/drillbox.py

83 lines
2.8 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/>.
2013-12-07 17:40:08 +01:00
from boxes import *
class Box(Boxes):
2016-03-15 21:29:03 +01:00
"""Not yet parametrized box for drills from 1 to 12.5mm
in 0.5mm steps, 3 holes each size"""
2016-03-08 22:27:55 +01:00
def __init__(self):
Boxes.__init__(self)
2016-03-08 22:27:55 +01:00
self.x, self.y, self.h = 120, 240, 60
2013-12-07 17:40:08 +01:00
def holesx(self):
self.fingerHolesAt(0, 5, self.x, angle=0)
self.fingerHolesAt(0, 25, self.x, angle=0)
def holesy(self):
self.fingerHolesAt(0, 5, self.y, angle=0)
self.fingerHolesAt(0, 25, self.y, angle=0)
def drillholes(self):
for i in range(6):
for j in range(4):
for k in range(3):
r = (12.5-2*i-0.5*j) * 0.5
self.hole(i*20+10, j*60+k*20+10, r+0.05)
def description(self):
self.ctx.set_font_size(6)
for i in range(4):
for j in range(6):
self.rectangularHole(i*60+30, 20*j+10, 58, 14+1*j)
d = 2.5-0.5*i+2*j
self.text("%.1f" % d, i*60+20, 19*j+6,
align="center")
2013-12-07 17:40:08 +01:00
def render(self):
x, y, h = self.x, self.y, self.h
t = self.thickness
self.open()
self.edges["f"].settings.setValues(self.thickness, space=3, finger=3,
surroundingspaces=1)
2013-12-07 17:40:08 +01:00
self.moveTo(t, t)
self.rectangularWall(x, h, "FfeF", callback=[self.holesx],move="right")
self.rectangularWall(y, h, "FfeF", callback=[self.holesy], move="up")
self.rectangularWall(y, h, "FfeF", callback=[self.holesy])
self.rectangularWall(x, h, "FfeF", callback=[self.holesx],
move="left up")
self.rectangularWall(x, y, "ffff", move="up")
self.rectangularWall(x, y, "ffff", callback=[self.drillholes],
move="up")
self.rectangularWall(x, y, "ffff", callback=[self.drillholes,
self.description],
move="up")
2014-03-21 21:08:54 +01:00
self.close()
2013-12-07 17:40:08 +01:00
2016-03-23 22:05:06 +01:00
def main():
2016-03-08 22:27:55 +01:00
b = Box()
b.parseArgs()
b.render()
2016-03-23 22:05:06 +01:00
if __name__ == '__main__':
main()