DrillBox: Make layers adjustable

Now one can have any number of layers at any height. This may make the
generator useful for other application with custom hole patters on
different height. It also allows deleteing holes for short drills on the
lower layers.

Thanks to https://github.com/KittyDreadful for suggesting this!

Related: #339
This commit is contained in:
Florian Festi 2021-12-12 17:44:18 +01:00
parent 9b0ebad0e7
commit bfe39861fa
1 changed files with 23 additions and 16 deletions

View File

@ -24,7 +24,8 @@ class DrillBox(Boxes):
Boxes.__init__(self) Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings, self.addSettingsArgs(edges.FingerJointSettings,
space=3, finger=3, surroundingspaces=1) space=3, finger=3, surroundingspaces=1)
self.buildArgParser(sx="25*3", sy="60*4", h=60, bottom_edge="h") self.buildArgParser(sx="25*3", sy="60*4", sh="5:25:10",
bottom_edge="h")
self.argparser.add_argument( self.argparser.add_argument(
"--holes", "--holes",
action="store", action="store",
@ -47,15 +48,13 @@ class DrillBox(Boxes):
help="increment between holes", help="increment between holes",
) )
def holesx(self): def sideholes(self, l):
x = sum(self.sx) t = self.thickness
self.fingerHolesAt(0, 5, x, angle=0) h = -0.5 * t
self.fingerHolesAt(0, 25, x, angle=0) for d in self.sh[:-1]:
h += d + t
self.fingerHolesAt(0, h, l, angle=0)
def holesy(self):
y = sum(self.sy)
self.fingerHolesAt(0, 5, y, angle=0)
self.fingerHolesAt(0, 25, y, angle=0)
def drillholes(self, description=False): def drillholes(self, description=False):
y = 0 y = 0
@ -85,18 +84,26 @@ class DrillBox(Boxes):
def render(self): def render(self):
x = sum(self.sx) x = sum(self.sx)
y = sum(self.sy) y = sum(self.sy)
h = self.h
h = sum(self.sh) + self.thickness * (len(self.sh)-1)
b = self.bottom_edge b = self.bottom_edge
self.rectangularWall( self.rectangularWall(
x, h, b + "feF", callback=[self.holesx], move="right") x, h, b + "feF",
callback=[lambda: self.sideholes(x)], move="right")
self.rectangularWall( self.rectangularWall(
y, h, b + "feF", callback=[self.holesy], move="up") y, h, b + "feF", callback=[lambda: self.sideholes(y)], move="up")
self.rectangularWall( self.rectangularWall(
y, h, b + "feF", callback=[self.holesy]) y, h, b + "feF", callback=[lambda: self.sideholes(y)])
self.rectangularWall( self.rectangularWall(
x, h, b + "feF", callback=[self.holesx], move="left up") x, h, b + "feF",
callback=[lambda: self.sideholes(x)], move="left up")
if b != "e": if b != "e":
self.rectangularWall(x, y, "ffff", move="right") self.rectangularWall(x, y, "ffff", move="right")
self.rectangularWall(x, y, "ffff", callback=[self.drillholes], move="right") for d in self.sh[:-2]:
self.rectangularWall(x, y, "ffff", callback=[lambda: self.drillholes(description=True)], move="right") self.rectangularWall(
x, y, "ffff", callback=[self.drillholes], move="right")
self.rectangularWall(
x, y, "ffff",
callback=[lambda: self.drillholes(description=True)],
move="right")