Add tabs to Boxes.edge() and most Edge classes
and Boxes.polyline() Add to some parts of the Otto Bot
This commit is contained in:
parent
e0caa3aad8
commit
e5bb6a5d7a
|
@ -236,6 +236,9 @@ class Boxes:
|
|||
"--format", action="store", type=str, default="svg",
|
||||
choices=self.formats.getFormats(),
|
||||
help="format of resulting file")
|
||||
defaultgroup.add_argument(
|
||||
"--tabs", action="store", type=float, default=0.0,
|
||||
help="width of tabs holding th parts in place (not supported everywhere)")
|
||||
defaultgroup.add_argument(
|
||||
"--debug", action="store", type=boolarg, default=False,
|
||||
help="print surrounding boxes for some structures")
|
||||
|
@ -570,14 +573,31 @@ class Boxes:
|
|||
|
||||
self.continueDirection(rad)
|
||||
|
||||
def edge(self, length):
|
||||
def edge(self, length, tabs=0):
|
||||
"""
|
||||
Simple line
|
||||
:param length: length in mm
|
||||
|
||||
"""
|
||||
self.ctx.move_to(0, 0)
|
||||
self.ctx.line_to(length, 0)
|
||||
if tabs and self.tabs:
|
||||
if self.tabs > length:
|
||||
self.ctx.move_to(length, 0)
|
||||
else:
|
||||
tabs = min(tabs, max(1, int(length // (tabs*3*self.tabs))))
|
||||
l = (length - tabs * self.tabs) / tabs
|
||||
self.ctx.line_to(0.5*l, 0)
|
||||
for i in range(tabs-1):
|
||||
self.ctx.move_to((i+0.5)*l+self.tabs, 0)
|
||||
self.ctx.line_to((i+0.5)*l+self.tabs+l, 0)
|
||||
if tabs == 1:
|
||||
self.ctx.move_to((tabs-0.5)*l+self.tabs, 0)
|
||||
else:
|
||||
self.ctx.move_to((tabs-0.5)*l+2*self.tabs, 0)
|
||||
|
||||
self.ctx.line_to(length, 0)
|
||||
else:
|
||||
self.ctx.line_to(length, 0)
|
||||
self.ctx.translate(*self.ctx.get_current_point())
|
||||
|
||||
def curveTo(self, x1, y1, x2, y2, x3, y3):
|
||||
|
@ -612,7 +632,10 @@ class Boxes:
|
|||
else:
|
||||
self.corner(arg)
|
||||
else:
|
||||
self.edge(arg)
|
||||
if isinstance(arg, tuple):
|
||||
self.edge(*arg)
|
||||
else:
|
||||
self.edge(arg)
|
||||
|
||||
def bedBoltHole(self, length, bedBoltSettings=None):
|
||||
"""
|
||||
|
|
|
@ -263,9 +263,7 @@ class BaseEdge(object):
|
|||
|
||||
def __call__(self, length, **kw):
|
||||
"""Draw edge of length mm"""
|
||||
self.ctx.move_to(0, 0)
|
||||
self.ctx.line_to(length, 0)
|
||||
self.ctx.translate(*self.ctx.get_current_point())
|
||||
self.edge(length, tabs=2)
|
||||
|
||||
def startwidth(self):
|
||||
"""Amount of space the beginning of the edge is set below the inner space of the part """
|
||||
|
@ -583,7 +581,7 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
|
|||
s -= play
|
||||
leftover -= play
|
||||
|
||||
self.edge(leftover / 2.0)
|
||||
self.edge(leftover / 2.0, tabs=1)
|
||||
|
||||
l1,l2 = self.fingerLength(self.settings.angle)
|
||||
h = l1-l2
|
||||
|
@ -603,7 +601,7 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
|
|||
|
||||
self.polyline(0, -90 * p, h, 90 * p, f, 90 * p, h, -90 * p)
|
||||
|
||||
self.edge(leftover / 2.0)
|
||||
self.edge(leftover / 2.0, tabs=1)
|
||||
|
||||
def margin(self):
|
||||
""" """
|
||||
|
@ -775,13 +773,13 @@ class StackableEdge(BaseEdge):
|
|||
self.boxes.fingerHolesAt(0, s.height + self.settings.holedistance + 0.5 * self.boxes.thickness,
|
||||
length, 0)
|
||||
|
||||
self.boxes.edge(s.width)
|
||||
self.boxes.edge(s.width, tabs=1)
|
||||
self.boxes.corner(p * s.angle, r)
|
||||
self.boxes.corner(-p * s.angle, r)
|
||||
self.boxes.edge(length - 2 * s.width - 4 * l)
|
||||
self.boxes.corner(-p * s.angle, r)
|
||||
self.boxes.corner(p * s.angle, r)
|
||||
self.boxes.edge(s.width)
|
||||
self.boxes.edge(s.width, tabs=1)
|
||||
|
||||
def _height(self):
|
||||
return self.settings.height + self.settings.holedistance + self.settings.thickness
|
||||
|
@ -927,7 +925,8 @@ class Hinge(BaseEdge):
|
|||
if self.layout & 1:
|
||||
getattr(self, self.settings.style, self.outset)()
|
||||
|
||||
self.edge(l - (self.layout & 1) * hlen - bool(self.layout & 2) * hlen)
|
||||
self.edge(l - (self.layout & 1) * hlen - bool(self.layout & 2) * hlen,
|
||||
tabs=2)
|
||||
|
||||
if self.layout & 2:
|
||||
getattr(self, self.settings.style, self.outset)(True)
|
||||
|
@ -1048,15 +1047,15 @@ class HingePin(BaseEdge):
|
|||
|
||||
if self.layout & 1 and self.layout & 2:
|
||||
getattr(self, self.settings.style, self.outset)()
|
||||
self.edge(l - 2 * plen)
|
||||
self.edge(l - 2 * plen, tabs=2)
|
||||
getattr(self, self.settings.style, self.outset)(True)
|
||||
elif self.layout & 1:
|
||||
getattr(self, self.settings.style, self.outset)()
|
||||
self.edge(l - plen - glen)
|
||||
self.edge(l - plen - glen, tabs=2)
|
||||
self.edges['g'](glen)
|
||||
else:
|
||||
self.edges['g'](glen)
|
||||
self.edge(l - plen - glen)
|
||||
self.edge(l - plen - glen, tabs=2)
|
||||
getattr(self, self.settings.style, self.outset)(True)
|
||||
|
||||
#############################################################################
|
||||
|
@ -1296,7 +1295,9 @@ class CabinetHingeEdge(BaseEdge):
|
|||
if not (i % 2) ^ self.top:
|
||||
self.rectangularHole(2*t+0.5*t+p+i*(t+p), e+2.5*t, t, t)
|
||||
self.rectangularHole(l-(2*t+0.5*t+p+i*(t+p)), e+2.5*t, t, t)
|
||||
self.polyline(*([2*t, 0] + poly + [0, l - 2*(width+2*t), 0]+ list(reversed(poly)) + [0, 2*t]))
|
||||
self.polyline(*([2*t, 0] + poly))
|
||||
self.edge(l - 2*(width+2*t), tabs=2)
|
||||
self.polyline(*(list(reversed(poly)) + [0, 2*t]))
|
||||
|
||||
def parts(self, move=None):
|
||||
e, b = self.settings.eye, self.settings.bore
|
||||
|
@ -1573,7 +1574,7 @@ class ClickConnector(BaseEdge):
|
|||
self.finger(2 * t)
|
||||
self.hook(reverse=True)
|
||||
|
||||
self.edge(length - 2 * (6 * t + 2 * self.hookWidth()))
|
||||
self.edge(length - 2 * (6 * t + 2 * self.hookWidth()), tabs=2)
|
||||
|
||||
self.hook()
|
||||
self.finger(2 * t)
|
||||
|
@ -1609,7 +1610,7 @@ class ClickEdge(ClickConnector):
|
|||
90,
|
||||
0)
|
||||
self.polyline(*p1)
|
||||
self.edge(length - 2 * (6 * t + 2 * w) + 2 * o)
|
||||
self.edge(length - 2 * (6 * t + 2 * w) + 2 * o, tabs=2)
|
||||
self.polyline(*reversed(p1))
|
||||
|
||||
|
||||
|
@ -1671,7 +1672,7 @@ class DoveTailJoint(BaseEdge):
|
|||
|
||||
p = 1 if positive else -1
|
||||
|
||||
self.edge((s.size + leftover) / 2.0 + diffx - l1)
|
||||
self.edge((s.size + leftover) / 2.0 + diffx - l1, tabs=1)
|
||||
|
||||
for i in range(sections):
|
||||
self.corner(-1 * p * a, radius)
|
||||
|
@ -1685,7 +1686,7 @@ class DoveTailJoint(BaseEdge):
|
|||
if i < sections - 1: # all but the last
|
||||
self.edge(2 * (diffx - l1) + s.size)
|
||||
|
||||
self.edge((s.size + leftover) / 2.0 + diffx - l1)
|
||||
self.edge((s.size + leftover) / 2.0 + diffx - l1, tabs=1)
|
||||
self.ctx.translate(*self.ctx.get_current_point())
|
||||
|
||||
def margin(self):
|
||||
|
|
|
@ -55,7 +55,7 @@ class OttoLegs(Boxes):
|
|||
self.moveTo(r, 0)
|
||||
|
||||
for l in (x, y, x, y):
|
||||
self.polyline(l - 2*r, 45, r*2**0.5, 45)
|
||||
self.polyline((l - 2*r, 1), 45, r*2**0.5, 45)
|
||||
|
||||
self.move(x, y, move)
|
||||
|
||||
|
@ -74,7 +74,7 @@ class OttoLegs(Boxes):
|
|||
self.edges[edge](x)
|
||||
self.polyline(0, 90)
|
||||
self.cc(callback, 1)
|
||||
self.polyline(h, 90, f*x, 45, (2**0.5)*(1-f)*x, 45, h-(1-f)*x, 90)
|
||||
self.polyline(h, 90, (f*x, 2), 45, (2**0.5)*(1-f)*x, 45, h-(1-f)*x, 90)
|
||||
self.moveTo(tw, th, 180)
|
||||
self.ctx.stroke()
|
||||
self.move(tw, th, move)
|
||||
|
@ -88,7 +88,7 @@ class OttoLegs(Boxes):
|
|||
return
|
||||
self.moveTo(10, 10, 90)
|
||||
self.moveTo(3.45, 0, -90)
|
||||
self.polyline(0, (-264, 3.45), 0, 36, 6.55, 108, 0, (330, 9.0), 0, 108, 6.55)
|
||||
self.polyline(0, (-264, 3.45), 0, 36, (6.55, 2), 108, 0, (330, 9.0), 0, 108, (6.55, 2))
|
||||
self.move(20, 20, move)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue