Add edges for a sliding lid
Add to top_edges and support in Box2
This commit is contained in:
parent
2494aeb3ae
commit
33d11487de
|
@ -288,7 +288,7 @@ class Boxes:
|
|||
elif arg == "top_edge":
|
||||
self.argparser.add_argument(
|
||||
"--top_edge", action="store",
|
||||
type=ArgparseEdgeType("ecESikf"), choices=list("ecESikf"),
|
||||
type=ArgparseEdgeType("ecESikfL"), choices=list("ecESikfL"),
|
||||
default="e", help="edge type for top edge")
|
||||
elif arg == "outside":
|
||||
self.argparser.add_argument(
|
||||
|
@ -368,7 +368,15 @@ class Boxes:
|
|||
for i in range(1, 4):
|
||||
self.addPart(edges.Hinge(self, s, i))
|
||||
self.addPart(edges.HingePin(self, s, i))
|
||||
|
||||
# Sliding Lid
|
||||
s = edges.LidSettings(self.thickness, True, finger=2.0, space=2.0,
|
||||
surroundingspaces=1.0, play=0.05)
|
||||
self.addPart(edges.LidEdge(self, s))
|
||||
self.addPart(edges.LidHoleEdge(self, s))
|
||||
self.addPart(edges.LidSideRight(self, s))
|
||||
self.addPart(edges.LidSideLeft(self, s))
|
||||
self.addPart(edges.LidRight(self, s))
|
||||
self.addPart(edges.LidLeft(self, s))
|
||||
# Nuts
|
||||
self.addPart(NutHole(self, None))
|
||||
# Gears
|
||||
|
|
100
boxes/edges.py
100
boxes/edges.py
|
@ -575,7 +575,11 @@ class FingerHoleEdge(BaseEdge):
|
|||
description = "Edge (parallel Finger Joint Holes)"
|
||||
|
||||
def __init__(self, boxes, fingerHoles=None, **kw):
|
||||
super(FingerHoleEdge, self).__init__(boxes, None, **kw)
|
||||
settings = None
|
||||
if isinstance(fingerHoles, Settings):
|
||||
settings = fingerHoles
|
||||
fingerHoles = FingerHoles(boxes, settings)
|
||||
super(FingerHoleEdge, self).__init__(boxes, settings, **kw)
|
||||
|
||||
self.fingerHoles = fingerHoles or boxes.fingerHolesAt
|
||||
|
||||
|
@ -941,6 +945,100 @@ class HingePin(BaseEdge):
|
|||
getattr(self, self.settings.style)(True)
|
||||
|
||||
|
||||
#############################################################################
|
||||
#### Slide-in lid
|
||||
#############################################################################
|
||||
|
||||
class LidSettings(FingerJointSettings):
|
||||
absolute_params = FingerJointSettings.absolute_params.copy()
|
||||
relative_params = FingerJointSettings.relative_params.copy()
|
||||
|
||||
relative_params.update( {
|
||||
"play" : 0.05,
|
||||
"second_pin" : 2,
|
||||
} )
|
||||
|
||||
class LidEdge(FingerJointEdge):
|
||||
char = "l"
|
||||
description = "Edge for slide on lid"
|
||||
|
||||
class LidHoleEdge(FingerHoleEdge):
|
||||
char = "L"
|
||||
description = "Edge for slide on lid"
|
||||
|
||||
class LidRight(BaseEdge):
|
||||
char = "n"
|
||||
description = "Edge for slide on lid (right)"
|
||||
rightside = True
|
||||
|
||||
def __call__(self, length, **kw):
|
||||
t = self.boxes.thickness
|
||||
p = [t, 90, t, -90, length-t]
|
||||
pin = self.settings.second_pin
|
||||
|
||||
if pin:
|
||||
p[-1:] = [length-2*t-pin, -90, t, 90, pin, 90, t, -90, t]
|
||||
|
||||
if not self.rightside:
|
||||
p = list(reversed(p))
|
||||
self.polyline(*p)
|
||||
|
||||
def startwidth(self):
|
||||
if self.rightside: # or self.settings.second_pin:
|
||||
return self.boxes.thickness
|
||||
else:
|
||||
return 0.0
|
||||
|
||||
def endwidth(self):
|
||||
if not self.rightside: # or self.settings.second_pin:
|
||||
return self.boxes.thickness
|
||||
else:
|
||||
return 0.0
|
||||
|
||||
def margin(self):
|
||||
if not self.rightside: # and not self.settings.second_pin:
|
||||
return self.boxes.thickness
|
||||
else:
|
||||
return 0.0
|
||||
|
||||
class LidLeft(LidRight):
|
||||
char = "m"
|
||||
description = "Edge for slide on lid (left)"
|
||||
rightside = False
|
||||
|
||||
class LidSideRight(BaseEdge):
|
||||
char = "N"
|
||||
description = "Edge for slide on lid (box right)"
|
||||
|
||||
rightside = True
|
||||
def __call__(self, length, **kw):
|
||||
t = self.boxes.thickness
|
||||
s = self.settings.play
|
||||
pin = self.settings.second_pin
|
||||
|
||||
p = [t+s, -90, t+s, -90, 2*t+s, 90, t-s, 90, length+t]
|
||||
|
||||
if pin:
|
||||
p[-1:] = [p[-1]-t-2*pin, 90, 2*t+s, -90, 2*pin+s, -90, t+s, -90,
|
||||
pin, 90, t, 90, pin+t-s]
|
||||
if not self.rightside:
|
||||
p = list(reversed(p))
|
||||
self.polyline(*p)
|
||||
|
||||
def startwidth(self):
|
||||
return 2*self.boxes.thickness if not self.rightside else 0.0
|
||||
|
||||
def endwidth(self):
|
||||
return 2*self.boxes.thickness if self.rightside else 0.0
|
||||
|
||||
def margin(self):
|
||||
return 2*self.boxes.thickness # if not self.rightside else 0.0
|
||||
|
||||
class LidSideLeft(LidSideRight):
|
||||
char = "M"
|
||||
description = "Edge for slide on lid (box left)"
|
||||
rightside = False
|
||||
|
||||
#############################################################################
|
||||
#### Click Joints
|
||||
#############################################################################
|
||||
|
|
|
@ -100,6 +100,10 @@ class Box2(Boxes):
|
|||
t3 = "j"
|
||||
elif t1.char == "k":
|
||||
t2 = t4 = "e"
|
||||
elif t1.char == "L":
|
||||
t1 = "M"
|
||||
t2 = "e"
|
||||
t3 = "N"
|
||||
|
||||
self.edges["k"].settings.setValues(self.thickness, outset=True)
|
||||
|
||||
|
@ -125,6 +129,8 @@ class Box2(Boxes):
|
|||
self.rectangularWall(x, y, "CCCC", bedBolts=[d2, d3, d2, d3], move="up")
|
||||
elif self.top_edge == "f":
|
||||
self.rectangularWall(x, y, "FFFF", move="up")
|
||||
elif self.top_edge == "L":
|
||||
self.rectangularWall(x, y, "nlmE", move="up")
|
||||
elif self.top_edge == "i":
|
||||
self.rectangularWall(x, y, "IEJe", move="up")
|
||||
elif self.top_edge == "k":
|
||||
|
|
Loading…
Reference in New Issue