boxespy/boxes/generators/slatwalldrillbox.py

61 lines
2.3 KiB
Python
Raw Normal View History

2019-07-12 00:43:06 +02:00
#!/usr/bin/env python3
# Copyright (C) 2013-2019 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 .drillstand import DrillStand
2019-07-12 00:43:06 +02:00
class SlatwallDrillBox(DrillStand):
2019-07-12 00:43:06 +02:00
"""Box for drills with each compartment with a different height"""
ui_group = "SlatWall"
def __init__(self):
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(edges.SlatWallSettings)
self.buildArgParser(sx="25*6", sy="10:20:30", sh="25:40:60")
self.argparser.add_argument(
"--extra_height", action="store", type=float, default=15.0,
help="height difference left to right")
def render(self):
# Add slat wall edges
s = edges.SlatWallSettings(self.thickness, True,
**self.edgesettings.get("SlatWall", {}))
s.edgeObjects(self)
self.slatWallHolesAt = edges.SlatWallHoles(self, s)
t = self.thickness
sx, sy, sh = self.sx, self.sy, self.sh
self.x = x = sum(sx) + len(sx)*t - t
self.y = y = sum(sy) + len(sy)*t - t
bottom_angle = math.atan(self.extra_height / x) # radians
self.xOutsideWall(sh[0], "hFeF", move="up")
2019-07-12 00:43:06 +02:00
for i in range(1, len(sy)):
self.xWall(i, move="up")
self.xOutsideWall(sh[-1], "hCec", move="up")
2019-07-12 00:43:06 +02:00
self.rectangularWall(x/math.cos(bottom_angle)-t*math.tan(bottom_angle), y, "fefe", callback=[self.bottomCB], move="up")
2019-07-12 00:43:06 +02:00
self.sideWall(edges="eBf", move="right")
for i in range(1, len(sx)):
2019-07-12 00:43:06 +02:00
self.yWall(i, move="right")
self.sideWall(self.extra_height, edges="eBf", move="right")