boxespy/boxes/generators/drillbox.py

70 lines
2.5 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 *
2016-08-17 15:07:41 +02:00
2016-07-31 14:15:06 +02:00
class DrillBox(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-08-17 15:07:41 +02:00
2016-03-08 22:27:55 +01:00
def __init__(self):
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
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):
2016-08-17 15:07:41 +02:00
r = (12.5 - 2 * i - 0.5 * j) * 0.5
self.hole(i * 20 + 10, j * 60 + k * 20 + 10, r + 0.05)
2013-12-07 17:40:08 +01:00
def descriptionText(self):
2013-12-07 17:40:08 +01:00
self.ctx.set_font_size(6)
for i in range(4):
for j in range(6):
2016-08-17 15:07:41 +02:00
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
2016-08-17 15:07:41 +02:00
self.edges["f"].settings.setValues(self.thickness, space=3, finger=3, surroundingspaces=1)
2016-08-17 15:07:41 +02:00
self.rectangularWall(x, h, "FfeF", callback=[self.holesx], move="right")
2013-12-07 17:40:08 +01:00
self.rectangularWall(y, h, "FfeF", callback=[self.holesy], move="up")
self.rectangularWall(y, h, "FfeF", callback=[self.holesy])
2016-08-17 15:07:41 +02:00
self.rectangularWall(x, h, "FfeF", callback=[self.holesx], move="left up")
2013-12-07 17:40:08 +01:00
self.rectangularWall(x, y, "ffff", move="up")
2016-08-17 15:07:41 +02:00
self.rectangularWall(x, y, "ffff", callback=[self.drillholes], move="up")
self.rectangularWall(x, y, "ffff", callback=[self.drillholes, self.descriptionText], move="up")
2013-12-07 17:40:08 +01:00
2016-08-17 15:07:41 +02:00