edges: add typing
This commit is contained in:
parent
2a044e7829
commit
71ddb11cee
330
boxes/edges.py
330
boxes/edges.py
|
@ -25,19 +25,19 @@ from typing import Any
|
||||||
from boxes import gears
|
from boxes import gears
|
||||||
|
|
||||||
|
|
||||||
def argparseSections(s):
|
def argparseSections(s: str) -> list[float]:
|
||||||
"""
|
"""
|
||||||
Parse sections parameter
|
Parse sections parameter
|
||||||
|
|
||||||
:param s: string to parse
|
:param s: string to parse
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = []
|
result: list[float] = []
|
||||||
|
|
||||||
s = re.split(r"\s|:", s)
|
parse = re.split(r"\s|:", s)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for part in s:
|
for part in parse:
|
||||||
m = re.match(r"^(\d+(\.\d+)?)/(\d+)$", part)
|
m = re.match(r"^(\d+(\.\d+)?)/(\d+)$", part)
|
||||||
if m:
|
if m:
|
||||||
n = int(m.group(3))
|
n = int(m.group(3))
|
||||||
|
@ -58,7 +58,7 @@ def argparseSections(s):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def getDescriptions():
|
def getDescriptions() -> dict:
|
||||||
d = {edge.char: edge.description for edge in globals().values()
|
d = {edge.char: edge.description for edge in globals().values()
|
||||||
if inspect.isclass(edge) and issubclass(edge, BaseEdge)
|
if inspect.isclass(edge) and issubclass(edge, BaseEdge)
|
||||||
and edge.char}
|
and edge.char}
|
||||||
|
@ -81,21 +81,21 @@ class BoltPolicy:
|
||||||
(fingers of a finger joint)
|
(fingers of a finger joint)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def drawbolt(self, pos):
|
def drawbolt(self, pos) -> bool:
|
||||||
"""Add a bolt to this segment?
|
"""Add a bolt to this segment?
|
||||||
|
|
||||||
:param pos: number of the finger
|
:param pos: number of the finger
|
||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def numFingers(self, numfingers):
|
def numFingers(self, numFingers: int) -> int:
|
||||||
"""Return next smaller, possible number of fingers
|
"""Return next smaller, possible number of fingers
|
||||||
|
|
||||||
:param numfingers: number of fingers to aim for
|
:param numFingers: number of fingers to aim for
|
||||||
"""
|
"""
|
||||||
return numfingers
|
return numFingers
|
||||||
|
|
||||||
def _even(self, numFingers):
|
def _even(self, numFingers: int) -> int:
|
||||||
"""
|
"""
|
||||||
Return same or next smaller even number
|
Return same or next smaller even number
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class BoltPolicy:
|
||||||
"""
|
"""
|
||||||
return (numFingers // 2) * 2
|
return (numFingers // 2) * 2
|
||||||
|
|
||||||
def _odd(self, numFingers):
|
def _odd(self, numFingers: int) -> int:
|
||||||
"""
|
"""
|
||||||
Return same or next smaller odd number
|
Return same or next smaller odd number
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ class BoltPolicy:
|
||||||
class Bolts(BoltPolicy):
|
class Bolts(BoltPolicy):
|
||||||
"""Distribute a fixed number of bolts evenly"""
|
"""Distribute a fixed number of bolts evenly"""
|
||||||
|
|
||||||
def __init__(self, bolts=1) -> None:
|
def __init__(self, bolts: int = 1) -> None:
|
||||||
self.bolts = bolts
|
self.bolts = bolts
|
||||||
|
|
||||||
def numFingers(self, numFingers):
|
def numFingers(self, numFingers: int) -> int:
|
||||||
if self.bolts % 2:
|
if self.bolts % 2:
|
||||||
self.fingers = self._even(numFingers)
|
self.fingers = self._even(numFingers)
|
||||||
else:
|
else:
|
||||||
|
@ -213,7 +213,7 @@ class Settings:
|
||||||
choices=choices,
|
choices=choices,
|
||||||
help=descriptions.get(name))
|
help=descriptions.get(name))
|
||||||
|
|
||||||
def __init__(self, thickness, relative=True, **kw) -> None:
|
def __init__(self, thickness, relative: bool = True, **kw) -> None:
|
||||||
self.values = {}
|
self.values = {}
|
||||||
for name, value in self.absolute_params.items():
|
for name, value in self.absolute_params.items():
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
|
@ -230,7 +230,7 @@ class Settings:
|
||||||
self.values[name] = value * factor
|
self.values[name] = value * factor
|
||||||
self.setValues(thickness, relative, **kw)
|
self.setValues(thickness, relative, **kw)
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="", add=True):
|
def edgeObjects(self, boxes, chars: str = "", add: bool = True):
|
||||||
"""
|
"""
|
||||||
Generate Edge objects using this kind of settings
|
Generate Edge objects using this kind of settings
|
||||||
|
|
||||||
|
@ -238,10 +238,10 @@ class Settings:
|
||||||
:param chars: sequence of chars to be used by Edge objects
|
:param chars: sequence of chars to be used by Edge objects
|
||||||
:param add: add the resulting Edge objects to the Boxes object's edges
|
:param add: add the resulting Edge objects to the Boxes object's edges
|
||||||
"""
|
"""
|
||||||
edges = []
|
edges: list[Any] = []
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
|
||||||
def _edgeObjects(self, edges, boxes, chars, add):
|
def _edgeObjects(self, edges, boxes, chars: str, add: bool):
|
||||||
for i, edge in enumerate(edges):
|
for i, edge in enumerate(edges):
|
||||||
try:
|
try:
|
||||||
char = chars[i]
|
char = chars[i]
|
||||||
|
@ -254,7 +254,7 @@ class Settings:
|
||||||
boxes.addParts(edges)
|
boxes.addParts(edges)
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
def setValues(self, thickness, relative=True, **kw):
|
def setValues(self, thickness, relative: bool = True, **kw):
|
||||||
"""
|
"""
|
||||||
Set values
|
Set values
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ class Settings:
|
||||||
self.__class__.__name__, name))
|
self.__class__.__name__, name))
|
||||||
self.checkValues()
|
self.checkValues()
|
||||||
|
|
||||||
def checkValues(self):
|
def checkValues(self) -> None:
|
||||||
"""
|
"""
|
||||||
Check if all values are in the right range. Raise ValueError if needed
|
Check if all values are in the right range. Raise ValueError if needed
|
||||||
"""
|
"""
|
||||||
|
@ -295,7 +295,7 @@ class Settings:
|
||||||
class BaseEdge:
|
class BaseEdge:
|
||||||
"""Abstract base class for all Edges"""
|
"""Abstract base class for all Edges"""
|
||||||
char: str | None = None
|
char: str | None = None
|
||||||
description = "Abstract Edge Class"
|
description: str = "Abstract Edge Class"
|
||||||
|
|
||||||
def __init__(self, boxes, settings) -> None:
|
def __init__(self, boxes, settings) -> None:
|
||||||
self.boxes = boxes
|
self.boxes = boxes
|
||||||
|
@ -310,26 +310,26 @@ class BaseEdge:
|
||||||
def __call__(self, length, **kw):
|
def __call__(self, length, **kw):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
"""Amount of space the beginning of the edge is set below the inner space of the part """
|
"""Amount of space the beginning of the edge is set below the inner space of the part """
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return self.startwidth()
|
return self.startwidth()
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
"""Space needed right of the starting point"""
|
"""Space needed right of the starting point"""
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def spacing(self):
|
def spacing(self) -> float:
|
||||||
"""Space the edge needs outside of the inner space of the part"""
|
"""Space the edge needs outside of the inner space of the part"""
|
||||||
return self.startwidth() + self.margin()
|
return self.startwidth() + self.margin()
|
||||||
|
|
||||||
def startAngle(self):
|
def startAngle(self) -> float:
|
||||||
"""Not yet supported"""
|
"""Not yet supported"""
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def endAngle(self):
|
def endAngle(self) -> float:
|
||||||
"""Not yet supported"""
|
"""Not yet supported"""
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ class OutSetEdge(Edge):
|
||||||
description = "Straight Edge (outset by thickness)"
|
description = "Straight Edge (outset by thickness)"
|
||||||
positive = True
|
positive = True
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ Values:
|
||||||
"d_head": 6.5
|
"d_head": 6.5
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="G", add=True):
|
def edgeObjects(self, boxes, chars: str = "G", add: bool = True):
|
||||||
edges = [MountingEdge(boxes, self)]
|
edges = [MountingEdge(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
|
||||||
|
@ -414,13 +414,13 @@ class MountingEdge(BaseEdge):
|
||||||
description = """Edge with pear shaped mounting holes""" # for slide-on mounting using flat-head screws"""
|
description = """Edge with pear shaped mounting holes""" # for slide-on mounting using flat-head screws"""
|
||||||
char = 'G'
|
char = 'G'
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if self.settings.style == MountingSettings.PARAM_TAB:
|
if self.settings.style == MountingSettings.PARAM_TAB:
|
||||||
return 2.75 * self.boxes.thickness + self.settings.d_head
|
return 2.75 * self.boxes.thickness + self.settings.d_head
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
if self.settings.style == MountingSettings.PARAM_EXT:
|
if self.settings.style == MountingSettings.PARAM_EXT:
|
||||||
return 2.5 * self.boxes.thickness + self.settings.d_head
|
return 2.5 * self.boxes.thickness + self.settings.d_head
|
||||||
else:
|
else:
|
||||||
|
@ -537,31 +537,31 @@ Values:
|
||||||
"interleave": False,
|
"interleave": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="zZ", add=True):
|
def edgeObjects(self, boxes, chars: str = "zZ", add: bool = True):
|
||||||
edges = [GroovedEdge(boxes, self),
|
edges = [GroovedEdge(boxes, self),
|
||||||
GroovedEdgeCounterPart(boxes, self)]
|
GroovedEdgeCounterPart(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
|
||||||
|
|
||||||
class GroovedEdgeBase(BaseEdge):
|
class GroovedEdgeBase(BaseEdge):
|
||||||
def is_inverse(self):
|
def is_inverse(self) -> bool:
|
||||||
return self.settings.inverse != self.inverse
|
return self.settings.inverse != self.inverse
|
||||||
|
|
||||||
def groove_arc(self, width, angle=90, inv=-1.0):
|
def groove_arc(self, width, angle: float = 90.0, inv: float = -1.0) -> None:
|
||||||
side_length = width / math.sin(math.radians(angle)) / 2
|
side_length = width / math.sin(math.radians(angle)) / 2
|
||||||
self.corner(inv * -angle)
|
self.corner(inv * -angle)
|
||||||
self.corner(inv * angle, side_length)
|
self.corner(inv * angle, side_length)
|
||||||
self.corner(inv * angle, side_length)
|
self.corner(inv * angle, side_length)
|
||||||
self.corner(inv * -angle)
|
self.corner(inv * -angle)
|
||||||
|
|
||||||
def groove_soft_arc(self, width, angle=60, inv=-1.0):
|
def groove_soft_arc(self, width, angle: float = 60.0, inv: float = -1.0) -> None:
|
||||||
side_length = width / math.sin(math.radians(angle)) / 4
|
side_length = width / math.sin(math.radians(angle)) / 4
|
||||||
self.corner(inv * -angle, side_length)
|
self.corner(inv * -angle, side_length)
|
||||||
self.corner(inv * angle, side_length)
|
self.corner(inv * angle, side_length)
|
||||||
self.corner(inv * angle, side_length)
|
self.corner(inv * angle, side_length)
|
||||||
self.corner(inv * -angle, side_length)
|
self.corner(inv * -angle, side_length)
|
||||||
|
|
||||||
def groove_triangle(self, width, angle=45, inv=-1.0):
|
def groove_triangle(self, width, angle: float = 45.0, inv: float = -1.0) -> None:
|
||||||
side_length = width / math.cos(math.radians(angle)) / 2
|
side_length = width / math.cos(math.radians(angle)) / 2
|
||||||
self.corner(inv * -angle)
|
self.corner(inv * -angle)
|
||||||
self.edge(side_length)
|
self.edge(side_length)
|
||||||
|
@ -651,7 +651,7 @@ Values:
|
||||||
|
|
||||||
* absolute_params
|
* absolute_params
|
||||||
|
|
||||||
* style : "wave : "wave" or "bumps"
|
* style : "wave" : "wave" or "bumps"
|
||||||
* outset : True : extend outward the straight edge
|
* outset : True : extend outward the straight edge
|
||||||
|
|
||||||
* relative (in multiples of thickness)
|
* relative (in multiples of thickness)
|
||||||
|
@ -669,7 +669,7 @@ Values:
|
||||||
"depth": 0.3,
|
"depth": 0.3,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="g", add=True):
|
def edgeObjects(self, boxes, chars: str = "g", add: bool = True):
|
||||||
edges = [GrippingEdge(boxes, self)]
|
edges = [GrippingEdge(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ class GrippingEdge(BaseEdge):
|
||||||
description = """Corrugated edge useful as an gipping area"""
|
description = """Corrugated edge useful as an gipping area"""
|
||||||
char = 'g'
|
char = 'g'
|
||||||
|
|
||||||
def wave(self, length):
|
def wave(self, length) -> None:
|
||||||
depth = self.settings.depth
|
depth = self.settings.depth
|
||||||
grooves = int(length // (depth * 2.0)) + 1
|
grooves = int(length // (depth * 2.0)) + 1
|
||||||
depth = length / grooves / 4.0
|
depth = length / grooves / 4.0
|
||||||
|
@ -689,7 +689,7 @@ class GrippingEdge(BaseEdge):
|
||||||
self.corner(o * 180, depth)
|
self.corner(o * 180, depth)
|
||||||
self.corner(o * -90, depth)
|
self.corner(o * -90, depth)
|
||||||
|
|
||||||
def bumps(self, length):
|
def bumps(self, length) -> None:
|
||||||
depth = self.settings.depth
|
depth = self.settings.depth
|
||||||
grooves = int(length // (depth * 2.0)) + 1
|
grooves = int(length // (depth * 2.0)) + 1
|
||||||
depth = length / grooves / 2.0
|
depth = length / grooves / 2.0
|
||||||
|
@ -712,7 +712,7 @@ class GrippingEdge(BaseEdge):
|
||||||
self.edge(depth)
|
self.edge(depth)
|
||||||
self.corner(90)
|
self.corner(90)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if self.settings.outset:
|
if self.settings.outset:
|
||||||
return self.settings.depth
|
return self.settings.depth
|
||||||
else:
|
else:
|
||||||
|
@ -735,13 +735,13 @@ class CompoundEdge(BaseEdge):
|
||||||
self.lengths = lengths
|
self.lengths = lengths
|
||||||
self.length = sum(lengths)
|
self.length = sum(lengths)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.types[0].startwidth()
|
return self.types[0].startwidth()
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return self.types[-1].endwidth()
|
return self.types[-1].endwidth()
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return max(e.margin() + e.startwidth() for e in self.types) - self.types[0].startwidth()
|
return max(e.margin() + e.startwidth() for e in self.types) - self.types[0].startwidth()
|
||||||
|
|
||||||
def __call__(self, length, **kw):
|
def __call__(self, length, **kw):
|
||||||
|
@ -786,20 +786,20 @@ class SlottedEdge(BaseEdge):
|
||||||
"""Edge with multiple slots"""
|
"""Edge with multiple slots"""
|
||||||
description = "Straight Edge with slots"
|
description = "Straight Edge with slots"
|
||||||
|
|
||||||
def __init__(self, boxes, sections, edge="e", slots=0) -> None:
|
def __init__(self, boxes, sections, edge: str = "e", slots: int = 0) -> None:
|
||||||
super().__init__(boxes, Settings(boxes.thickness))
|
super().__init__(boxes, Settings(boxes.thickness))
|
||||||
|
|
||||||
self.edge = self.edges.get(edge, edge)
|
self.edge = self.edges.get(edge, edge)
|
||||||
self.sections = sections
|
self.sections = sections
|
||||||
self.slots = slots
|
self.slots = slots
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.edge.startwidth()
|
return self.edge.startwidth()
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return self.edge.endwidth()
|
return self.edge.endwidth()
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.edge.margin()
|
return self.edge.margin()
|
||||||
|
|
||||||
def __call__(self, length, **kw):
|
def __call__(self, length, **kw):
|
||||||
|
@ -856,11 +856,11 @@ Values:
|
||||||
"bottom_lip": 0.0,
|
"bottom_lip": 0.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def checkValues(self):
|
def checkValues(self) -> None:
|
||||||
if abs(self.space + self.finger) < 0.1:
|
if abs(self.space + self.finger) < 0.1:
|
||||||
raise ValueError("FingerJointSettings: space + finger must not be close to zero")
|
raise ValueError("FingerJointSettings: space + finger must not be close to zero")
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="fFh", add=True):
|
def edgeObjects(self, boxes, chars: str = "fFh", add: bool = True):
|
||||||
edges = [FingerJointEdge(boxes, self),
|
edges = [FingerJointEdge(boxes, self),
|
||||||
FingerJointEdgeCounterPart(boxes, self),
|
FingerJointEdgeCounterPart(boxes, self),
|
||||||
FingerHoleEdge(boxes, self),
|
FingerHoleEdge(boxes, self),
|
||||||
|
@ -870,12 +870,11 @@ Values:
|
||||||
|
|
||||||
class FingerJointBase:
|
class FingerJointBase:
|
||||||
|
|
||||||
def calcFingers(self, length, bedBolts):
|
def calcFingers(self, length: float, bedBolts) -> tuple[int, float]:
|
||||||
space, finger = self.settings.space, self.settings.finger
|
space, finger = self.settings.space, self.settings.finger # type: ignore
|
||||||
fingers = int((length - (self.settings.surroundingspaces - 1) * space) //
|
fingers = int((length - (self.settings.surroundingspaces - 1) * space) // (space + finger)) # type: ignore
|
||||||
(space + finger))
|
|
||||||
# shrink surrounding space up to half a thickness each side
|
# shrink surrounding space up to half a thickness each side
|
||||||
if fingers == 0 and length > finger + 1.0 * self.settings.thickness:
|
if fingers == 0 and length > finger + 1.0 * self.settings.thickness: # type: ignore
|
||||||
fingers = 1
|
fingers = 1
|
||||||
if not finger:
|
if not finger:
|
||||||
fingers = 0
|
fingers = 0
|
||||||
|
@ -889,22 +888,21 @@ class FingerJointBase:
|
||||||
|
|
||||||
return fingers, leftover
|
return fingers, leftover
|
||||||
|
|
||||||
def fingerLength(self, angle):
|
def fingerLength(self, angle: float) -> tuple[float, float]:
|
||||||
# sharp corners
|
# sharp corners
|
||||||
if angle >= 90 or angle <= -90:
|
if angle >= 90 or angle <= -90:
|
||||||
return self.settings.thickness + self.settings.extra_length, 0
|
return self.settings.thickness + self.settings.extra_length, 0.0 # type: ignore
|
||||||
|
|
||||||
# inner blunt corners
|
# inner blunt corners
|
||||||
if angle < 0:
|
if angle < 0:
|
||||||
return (math.sin(math.radians(-angle)) * self.settings.thickness +
|
return (math.sin(math.radians(-angle)) * self.settings.thickness + self.settings.extra_length), 0 # type: ignore
|
||||||
self.settings.extra_length), 0
|
|
||||||
|
|
||||||
# 0 to 90 (blunt corners)
|
# 0 to 90 (blunt corners)
|
||||||
a = 90 - (180 - angle) / 2.0
|
a = 90 - (180 - angle) / 2.0
|
||||||
fingerlength = self.settings.thickness * math.tan(math.radians(a))
|
fingerlength = self.settings.thickness * math.tan(math.radians(a)) # type: ignore
|
||||||
b = 90 - 2 * a
|
b = 90 - 2 * a
|
||||||
spacerecess = -math.sin(math.radians(b)) * fingerlength
|
spacerecess = -math.sin(math.radians(b)) * fingerlength
|
||||||
return fingerlength + self.settings.extra_length, spacerecess
|
return fingerlength + self.settings.extra_length, spacerecess # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class FingerJointEdge(BaseEdge, FingerJointBase):
|
class FingerJointEdge(BaseEdge, FingerJointBase):
|
||||||
|
@ -913,7 +911,7 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
|
||||||
description = "Finger Joint"
|
description = "Finger Joint"
|
||||||
positive = True
|
positive = True
|
||||||
|
|
||||||
def draw_finger(self, f, h, style, positive=True, firsthalf=True):
|
def draw_finger(self, f, h, style, positive: bool = True, firsthalf: bool = True) -> None:
|
||||||
t = self.settings.thickness
|
t = self.settings.thickness
|
||||||
|
|
||||||
if positive:
|
if positive:
|
||||||
|
@ -997,7 +995,7 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
|
||||||
|
|
||||||
self.edge(leftover / 2.0, tabs=1)
|
self.edge(leftover / 2.0, tabs=1)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
""" """
|
""" """
|
||||||
widths = self.fingerLength(self.settings.angle)
|
widths = self.fingerLength(self.settings.angle)
|
||||||
if self.positive:
|
if self.positive:
|
||||||
|
@ -1007,7 +1005,7 @@ class FingerJointEdge(BaseEdge, FingerJointBase):
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
widths = self.fingerLength(self.settings.angle)
|
widths = self.fingerLength(self.settings.angle)
|
||||||
return widths[self.positive]
|
return widths[self.positive]
|
||||||
|
|
||||||
|
@ -1094,11 +1092,11 @@ class FingerHoleEdge(BaseEdge):
|
||||||
self.rectangularWall(length - 1.05 * self.boxes.thickness, h)
|
self.rectangularWall(length - 1.05 * self.boxes.thickness, h)
|
||||||
self.edge(length, tabs=2)
|
self.edge(length, tabs=2)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
""" """
|
""" """
|
||||||
return self.fingerHoles.settings.edge_width + self.settings.thickness
|
return self.fingerHoles.settings.edge_width + self.settings.thickness
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if self.settings.bottom_lip:
|
if self.settings.bottom_lip:
|
||||||
return self.settings.bottom_lip + self.fingerHoles.settings.edge_width + self.boxes.spacing
|
return self.settings.bottom_lip + self.fingerHoles.settings.edge_width + self.boxes.spacing
|
||||||
else:
|
else:
|
||||||
|
@ -1111,7 +1109,7 @@ class CrossingFingerHoleEdge(Edge):
|
||||||
description = "Edge (orthogonal Finger Joint Holes)"
|
description = "Edge (orthogonal Finger Joint Holes)"
|
||||||
char = '|'
|
char = '|'
|
||||||
|
|
||||||
def __init__(self, boxes, height, fingerHoles=None, outset=0.0, **kw) -> None:
|
def __init__(self, boxes, height, fingerHoles=None, outset: float = 0.0, **kw) -> None:
|
||||||
super().__init__(boxes, None, **kw)
|
super().__init__(boxes, None, **kw)
|
||||||
|
|
||||||
self.fingerHoles = fingerHoles or boxes.fingerHolesAt
|
self.fingerHoles = fingerHoles or boxes.fingerHolesAt
|
||||||
|
@ -1122,7 +1120,7 @@ class CrossingFingerHoleEdge(Edge):
|
||||||
self.fingerHoles(length / 2.0, self.outset + self.burn, self.height)
|
self.fingerHoles(length / 2.0, self.outset + self.burn, self.height)
|
||||||
super().__call__(length)
|
super().__call__(length)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.outset
|
return self.outset
|
||||||
|
|
||||||
|
|
||||||
|
@ -1159,13 +1157,13 @@ Values:
|
||||||
"bottom_stabilizers": 0.0,
|
"bottom_stabilizers": 0.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def checkValues(self):
|
def checkValues(self) -> None:
|
||||||
if self.angle < 20:
|
if self.angle < 20:
|
||||||
raise ValueError("StackableSettings: 'angle' is too small. Use value >= 20")
|
raise ValueError("StackableSettings: 'angle' is too small. Use value >= 20")
|
||||||
if self.angle > 260:
|
if self.angle > 260:
|
||||||
raise ValueError("StackableSettings: 'angle' is too big. Use value < 260")
|
raise ValueError("StackableSettings: 'angle' is too big. Use value < 260")
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="sSšŠ", add=True, fingersettings=None):
|
def edgeObjects(self, boxes, chars: str = "sSšŠ", add: bool = True, fingersettings=None):
|
||||||
fingersettings = fingersettings or boxes.edges["f"].settings
|
fingersettings = fingersettings or boxes.edges["f"].settings
|
||||||
edges = [StackableEdge(boxes, self, fingersettings),
|
edges = [StackableEdge(boxes, self, fingersettings),
|
||||||
StackableEdgeTop(boxes, self, fingersettings),
|
StackableEdgeTop(boxes, self, fingersettings),
|
||||||
|
@ -1212,10 +1210,10 @@ class StackableBaseEdge(BaseEdge):
|
||||||
def _height(self):
|
def _height(self):
|
||||||
return self.settings.height + self.settings.holedistance + self.settings.thickness
|
return self.settings.height + self.settings.holedistance + self.settings.thickness
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self._height() if self.bottom else 0
|
return self._height() if self.bottom else 0
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if self.bottom:
|
if self.bottom:
|
||||||
if self.settings.bottom_stabilizers:
|
if self.settings.bottom_stabilizers:
|
||||||
return self.settings.bottom_stabilizers + self.boxes.spacing
|
return self.settings.bottom_stabilizers + self.boxes.spacing
|
||||||
|
@ -1260,7 +1258,7 @@ class StackableHoleEdgeTop(StackableBaseEdge):
|
||||||
description = "Stackable edge with finger holes (top)"
|
description = "Stackable edge with finger holes (top)"
|
||||||
bottom = False
|
bottom = False
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.settings.thickness + self.settings.holedistance
|
return self.settings.thickness + self.settings.holedistance
|
||||||
|
|
||||||
def __call__(self, length, **kw):
|
def __call__(self, length, **kw):
|
||||||
|
@ -1307,11 +1305,11 @@ Values:
|
||||||
"grip_length": 0,
|
"grip_length": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def checkValues(self):
|
def checkValues(self) -> None:
|
||||||
if self.axle / self.thickness < 0.1:
|
if self.axle / self.thickness < 0.1:
|
||||||
raise ValueError("HingeSettings: 'axle' need to be at least 0.1 strong")
|
raise ValueError("HingeSettings: 'axle' need to be at least 0.1 strong")
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="iIjJkK", add=True):
|
def edgeObjects(self, boxes, chars: str = "iIjJkK", add: bool = True):
|
||||||
edges = [
|
edges = [
|
||||||
Hinge(boxes, self, 1),
|
Hinge(boxes, self, 1),
|
||||||
HingePin(boxes, self, 1),
|
HingePin(boxes, self, 1),
|
||||||
|
@ -1327,7 +1325,7 @@ class Hinge(BaseEdge):
|
||||||
char = 'i'
|
char = 'i'
|
||||||
description = "Straight edge with hinge eye"
|
description = "Straight edge with hinge eye"
|
||||||
|
|
||||||
def __init__(self, boxes, settings=None, layout=1) -> None:
|
def __init__(self, boxes, settings=None, layout: int = 1) -> None:
|
||||||
super().__init__(boxes, settings)
|
super().__init__(boxes, settings)
|
||||||
|
|
||||||
if not (0 < layout <= 3):
|
if not (0 < layout <= 3):
|
||||||
|
@ -1337,57 +1335,57 @@ class Hinge(BaseEdge):
|
||||||
self.char = "eijk"[layout]
|
self.char = "eijk"[layout]
|
||||||
self.description = self.description + ('', ' (start)', ' (end)', ' (both ends)')[layout]
|
self.description = self.description + ('', ' (start)', ' (end)', ' (both ends)')[layout]
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 3 * self.settings.thickness
|
return 3 * self.settings.thickness
|
||||||
|
|
||||||
def outset(self, _reversed=False):
|
def outset(self, _reversed: bool = False) -> None:
|
||||||
t = self.settings.thickness
|
t: float = self.settings.thickness
|
||||||
r = 0.5 * self.settings.axle
|
r = 0.5 * self.settings.axle
|
||||||
alpha = math.degrees(math.asin(0.5 * t / r))
|
alpha = math.degrees(math.asin(0.5 * t / r))
|
||||||
pinl = (self.settings.axle ** 2 - self.settings.thickness ** 2) ** 0.5 * self.settings.pinwidth
|
pinl = (self.settings.axle ** 2 - self.settings.thickness ** 2) ** 0.5 * self.settings.pinwidth
|
||||||
pos = math.cos(math.radians(alpha)) * r
|
pos = math.cos(math.radians(alpha)) * r
|
||||||
hinge = (
|
hinge = (
|
||||||
0,
|
0.,
|
||||||
90 - alpha, 0,
|
90. - alpha, 0.,
|
||||||
(-360, r), 0,
|
(-360., r), 0.,
|
||||||
90 + alpha,
|
90. + alpha,
|
||||||
t,
|
t,
|
||||||
90,
|
90.,
|
||||||
0.5 * t,
|
0.5 * t,
|
||||||
(180, t + pos), 0,
|
(180., t + pos), 0.,
|
||||||
(-90, 0.5 * t), 0
|
(-90., 0.5 * t), 0.
|
||||||
)
|
)
|
||||||
|
|
||||||
if _reversed:
|
if _reversed:
|
||||||
hinge = reversed(hinge)
|
hinge = reversed(hinge) # type: ignore
|
||||||
self.polyline(*hinge)
|
self.polyline(*hinge)
|
||||||
self.boxes.rectangularHole(-pos, -0.5 * t, pinl, self.settings.thickness)
|
self.boxes.rectangularHole(-pos, -0.5 * t, pinl, self.settings.thickness)
|
||||||
else:
|
else:
|
||||||
self.boxes.rectangularHole(pos, -0.5 * t, pinl, self.settings.thickness)
|
self.boxes.rectangularHole(pos, -0.5 * t, pinl, self.settings.thickness)
|
||||||
self.polyline(*hinge)
|
self.polyline(*hinge)
|
||||||
|
|
||||||
def outsetlen(self):
|
def outsetlen(self) -> float:
|
||||||
t = self.settings.thickness
|
t = self.settings.thickness
|
||||||
r = 0.5 * self.settings.axle
|
r = 0.5 * self.settings.axle
|
||||||
alpha = math.degrees(math.asin(0.5 * t / r))
|
alpha = math.degrees(math.asin(0.5 * t / r))
|
||||||
pos = math.cos(math.radians(alpha)) * r
|
pos = math.cos(math.radians(alpha)) * r
|
||||||
|
|
||||||
return 2 * pos + 1.5 * t
|
return 2.0 * pos + 1.5 * t
|
||||||
|
|
||||||
def flush(self, _reversed=False):
|
def flush(self, _reversed: bool = False) -> None:
|
||||||
t = self.settings.thickness
|
t = self.settings.thickness
|
||||||
|
|
||||||
hinge = (
|
hinge = (
|
||||||
0, -90,
|
0., -90.,
|
||||||
0.5 * t,
|
0.5 * t,
|
||||||
(180, 0.5 * self.settings.axle + self.settings.hingestrength), 0,
|
(180., 0.5 * self.settings.axle + self.settings.hingestrength), 0.,
|
||||||
(-90, 0.5 * t), 0
|
(-90., 0.5 * t), 0.
|
||||||
)
|
)
|
||||||
pos = 0.5 * self.settings.axle + self.settings.hingestrength
|
pos = 0.5 * self.settings.axle + self.settings.hingestrength
|
||||||
pinl = (self.settings.axle ** 2 - self.settings.thickness ** 2) ** 0.5 * self.settings.pinwidth
|
pinl = (self.settings.axle ** 2 - self.settings.thickness ** 2) ** 0.5 * self.settings.pinwidth
|
||||||
|
|
||||||
if _reversed:
|
if _reversed:
|
||||||
hinge = reversed(hinge)
|
hinge = reversed(hinge) # type: ignore
|
||||||
self.hole(0.5 * t + pos, -0.5 * t, 0.5 * self.settings.axle)
|
self.hole(0.5 * t + pos, -0.5 * t, 0.5 * self.settings.axle)
|
||||||
self.boxes.rectangularHole(0.5 * t + pos, -0.5 * t, pinl, self.settings.thickness)
|
self.boxes.rectangularHole(0.5 * t + pos, -0.5 * t, pinl, self.settings.thickness)
|
||||||
else:
|
else:
|
||||||
|
@ -1396,8 +1394,8 @@ class Hinge(BaseEdge):
|
||||||
|
|
||||||
self.polyline(*hinge)
|
self.polyline(*hinge)
|
||||||
|
|
||||||
def flushlen(self):
|
def flushlen(self) -> float:
|
||||||
return self.settings.axle + 2 * self.settings.hingestrength + 0.5 * self.settings.thickness
|
return self.settings.axle + 2.0 * self.settings.hingestrength + 0.5 * self.settings.thickness
|
||||||
|
|
||||||
def __call__(self, l, **kw):
|
def __call__(self, l, **kw):
|
||||||
hlen = getattr(self, self.settings.style + 'len', self.outsetlen)()
|
hlen = getattr(self, self.settings.style + 'len', self.outsetlen)()
|
||||||
|
@ -1416,7 +1414,7 @@ class HingePin(BaseEdge):
|
||||||
char = 'I'
|
char = 'I'
|
||||||
description = "Edge with hinge pin"
|
description = "Edge with hinge pin"
|
||||||
|
|
||||||
def __init__(self, boxes, settings=None, layout=1) -> None:
|
def __init__(self, boxes, settings=None, layout: int = 1) -> None:
|
||||||
super().__init__(boxes, settings)
|
super().__init__(boxes, settings)
|
||||||
|
|
||||||
if not (0 < layout <= 3):
|
if not (0 < layout <= 3):
|
||||||
|
@ -1426,47 +1424,47 @@ class HingePin(BaseEdge):
|
||||||
self.char = "EIJK"[layout]
|
self.char = "EIJK"[layout]
|
||||||
self.description = self.description + ('', ' (start)', ' (end)', ' (both ends)')[layout]
|
self.description = self.description + ('', ' (start)', ' (end)', ' (both ends)')[layout]
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
if self.layout & 1:
|
if self.layout & 1:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return self.settings.outset * self.boxes.thickness
|
return self.settings.outset * self.boxes.thickness
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
if self.layout & 2:
|
if self.layout & 2:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return self.settings.outset * self.boxes.thickness
|
return self.settings.outset * self.boxes.thickness
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.thickness
|
return self.settings.thickness
|
||||||
|
|
||||||
def outset(self, _reversed=False):
|
def outset(self, _reversed: bool = False) -> None:
|
||||||
t = self.settings.thickness
|
t: float = self.settings.thickness
|
||||||
r = 0.5 * self.settings.axle
|
r = 0.5 * self.settings.axle
|
||||||
alpha = math.degrees(math.asin(0.5 * t / r))
|
alpha = math.degrees(math.asin(0.5 * t / r))
|
||||||
pos = math.cos(math.radians(alpha)) * r
|
pos = math.cos(math.radians(alpha)) * r
|
||||||
pinl = (self.settings.axle ** 2 - self.settings.thickness ** 2) ** 0.5 * self.settings.pinwidth
|
pinl = (self.settings.axle ** 2 - self.settings.thickness ** 2) ** 0.5 * self.settings.pinwidth
|
||||||
pin = (pos - 0.5 * pinl, -90,
|
pin = (pos - 0.5 * pinl, -90.,
|
||||||
t, 90,
|
t, 90.,
|
||||||
pinl,
|
pinl,
|
||||||
90,
|
90.,
|
||||||
t,
|
t,
|
||||||
-90)
|
-90.)
|
||||||
|
|
||||||
if self.settings.outset:
|
if self.settings.outset:
|
||||||
pin += (
|
pin += ( # type: ignore
|
||||||
pos - 0.5 * pinl + 1.5 * t,
|
pos - 0.5 * pinl + 1.5 * t,
|
||||||
-90,
|
-90.,
|
||||||
t,
|
t,
|
||||||
90,
|
90.,
|
||||||
0,
|
0.,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pin += (pos - 0.5 * pinl,)
|
pin += (pos - 0.5 * pinl,) # type: ignore
|
||||||
|
|
||||||
if _reversed:
|
if _reversed:
|
||||||
pin = reversed(pin)
|
pin = reversed(pin) # type: ignore
|
||||||
|
|
||||||
self.polyline(*pin)
|
self.polyline(*pin)
|
||||||
|
|
||||||
|
@ -1481,29 +1479,29 @@ class HingePin(BaseEdge):
|
||||||
else:
|
else:
|
||||||
return 2 * pos
|
return 2 * pos
|
||||||
|
|
||||||
def flush(self, _reversed=False):
|
def flush(self, _reversed: bool = False) -> None:
|
||||||
t = self.settings.thickness
|
t: float = self.settings.thickness
|
||||||
pinl = (self.settings.axle ** 2 - t ** 2) ** 0.5 * self.settings.pinwidth
|
pinl = (self.settings.axle ** 2 - t ** 2) ** 0.5 * self.settings.pinwidth
|
||||||
d = (self.settings.axle - pinl) / 2.0
|
d = (self.settings.axle - pinl) / 2.0
|
||||||
pin = (self.settings.hingestrength + d, -90,
|
pin = (self.settings.hingestrength + d, -90.,
|
||||||
t, 90,
|
t, 90.,
|
||||||
pinl,
|
pinl,
|
||||||
90,
|
90.,
|
||||||
t,
|
t,
|
||||||
-90, d)
|
-90., d)
|
||||||
|
|
||||||
if self.settings.outset:
|
if self.settings.outset:
|
||||||
pin += (
|
pin += ( # type: ignore
|
||||||
0,
|
0.,
|
||||||
self.settings.hingestrength + 0.5 * t,
|
self.settings.hingestrength + 0.5 * t,
|
||||||
-90,
|
-90.,
|
||||||
t,
|
t,
|
||||||
90,
|
90.,
|
||||||
0,
|
0.,
|
||||||
)
|
)
|
||||||
|
|
||||||
if _reversed:
|
if _reversed:
|
||||||
pin = reversed(pin)
|
pin = reversed(pin) # type: ignore
|
||||||
|
|
||||||
self.polyline(*pin)
|
self.polyline(*pin)
|
||||||
|
|
||||||
|
@ -1569,19 +1567,19 @@ Values:
|
||||||
"finger_joints_on_lid": False,
|
"finger_joints_on_lid": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def checkValues(self):
|
def checkValues(self) -> None:
|
||||||
if self.pin_height / self.thickness < 1.2:
|
if self.pin_height / self.thickness < 1.2:
|
||||||
raise ValueError("ChestHingeSettings: 'pin_height' must be >= 1.2")
|
raise ValueError("ChestHingeSettings: 'pin_height' must be >= 1.2")
|
||||||
|
|
||||||
def pinheight(self):
|
def pinheight(self):
|
||||||
return ((0.9 * self.pin_height) ** 2 - self.thickness ** 2) ** 0.5
|
return ((0.9 * self.pin_height) ** 2 - self.thickness ** 2) ** 0.5
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="oOpPqQ", add=True):
|
def edgeObjects(self, boxes, chars: str = "oOpPqQ", add: bool = True):
|
||||||
edges = [
|
edges = [
|
||||||
ChestHinge(boxes, self),
|
ChestHinge(boxes, self),
|
||||||
ChestHinge(boxes, self, 1),
|
ChestHinge(boxes, self, True),
|
||||||
ChestHingeTop(boxes, self),
|
ChestHingeTop(boxes, self),
|
||||||
ChestHingeTop(boxes, self, 1),
|
ChestHingeTop(boxes, self, True),
|
||||||
ChestHingePin(boxes, self),
|
ChestHingePin(boxes, self),
|
||||||
ChestHingeFront(boxes, self),
|
ChestHingeFront(boxes, self),
|
||||||
]
|
]
|
||||||
|
@ -1593,7 +1591,7 @@ class ChestHinge(BaseEdge):
|
||||||
|
|
||||||
char = "o"
|
char = "o"
|
||||||
|
|
||||||
def __init__(self, boxes, settings=None, reversed=False) -> None:
|
def __init__(self, boxes, settings=None, reversed: bool = False) -> None:
|
||||||
super().__init__(boxes, settings)
|
super().__init__(boxes, settings)
|
||||||
|
|
||||||
self.reversed = reversed
|
self.reversed = reversed
|
||||||
|
@ -1628,18 +1626,18 @@ class ChestHinge(BaseEdge):
|
||||||
self.polyline(*poly)
|
self.polyline(*poly)
|
||||||
draw_rest_of_edge()
|
draw_rest_of_edge()
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if self.reversed:
|
if self.reversed:
|
||||||
return 0 * (self.settings.pin_height + self.settings.hinge_strength)
|
return 0 * (self.settings.pin_height + self.settings.hinge_strength)
|
||||||
else:
|
else:
|
||||||
return 1 * (self.settings.pin_height + self.settings.hinge_strength)
|
return 1 * (self.settings.pin_height + self.settings.hinge_strength)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
if self.reversed:
|
if self.reversed:
|
||||||
return self.settings.pin_height + self.settings.hinge_strength
|
return self.settings.pin_height + self.settings.hinge_strength
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
if self.reversed:
|
if self.reversed:
|
||||||
return 0
|
return 0
|
||||||
return self.settings.pin_height + self.settings.hinge_strength
|
return self.settings.pin_height + self.settings.hinge_strength
|
||||||
|
@ -1650,7 +1648,7 @@ class ChestHingeTop(ChestHinge):
|
||||||
|
|
||||||
char = "p"
|
char = "p"
|
||||||
|
|
||||||
def __init__(self, boxes, settings=None, reversed=False) -> None:
|
def __init__(self, boxes, settings=None, reversed: bool = False) -> None:
|
||||||
super().__init__(boxes, settings)
|
super().__init__(boxes, settings)
|
||||||
|
|
||||||
self.reversed = reversed
|
self.reversed = reversed
|
||||||
|
@ -1679,17 +1677,17 @@ class ChestHingeTop(ChestHinge):
|
||||||
self.polyline(*poly)
|
self.polyline(*poly)
|
||||||
draw_rest_of_edge()
|
draw_rest_of_edge()
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
if self.reversed:
|
if self.reversed:
|
||||||
return self.settings.play + self.settings.pin_height + self.settings.hinge_strength
|
return self.settings.play + self.settings.pin_height + self.settings.hinge_strength
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
if self.reversed:
|
if self.reversed:
|
||||||
return 0
|
return 0
|
||||||
return self.settings.play + self.settings.pin_height + self.settings.hinge_strength
|
return self.settings.play + self.settings.pin_height + self.settings.hinge_strength
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if self.reversed:
|
if self.reversed:
|
||||||
return 0.
|
return 0.
|
||||||
else:
|
else:
|
||||||
|
@ -1719,7 +1717,7 @@ class ChestHingePin(BaseEdge):
|
||||||
draw_rest_of_edge()
|
draw_rest_of_edge()
|
||||||
self.polyline(*(middle_segment + list(reversed(poly))))
|
self.polyline(*(middle_segment + list(reversed(poly))))
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return (self.settings.pin_height + self.settings.hinge_strength)
|
return (self.settings.pin_height + self.settings.hinge_strength)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1728,7 +1726,7 @@ class ChestHingeFront(Edge):
|
||||||
|
|
||||||
char = "Q"
|
char = "Q"
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.settings.pin_height + self.settings.hinge_strength
|
return self.settings.pin_height + self.settings.hinge_strength
|
||||||
|
|
||||||
|
|
||||||
|
@ -1766,7 +1764,7 @@ Values:
|
||||||
"spacing": 2.0,
|
"spacing": 2.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="uUvV", add=True):
|
def edgeObjects(self, boxes, chars: str = "uUvV", add: bool = True):
|
||||||
edges = [CabinetHingeEdge(boxes, self),
|
edges = [CabinetHingeEdge(boxes, self),
|
||||||
CabinetHingeEdge(boxes, self, top=True),
|
CabinetHingeEdge(boxes, self, top=True),
|
||||||
CabinetHingeEdge(boxes, self, angled=True),
|
CabinetHingeEdge(boxes, self, angled=True),
|
||||||
|
@ -1783,13 +1781,13 @@ class CabinetHingeEdge(BaseEdge):
|
||||||
char = "u"
|
char = "u"
|
||||||
description = "Edge with cabinet hinges"
|
description = "Edge with cabinet hinges"
|
||||||
|
|
||||||
def __init__(self, boxes, settings=None, top=False, angled=False) -> None:
|
def __init__(self, boxes, settings=None, top: bool = False, angled: bool = False) -> None:
|
||||||
super().__init__(boxes, settings)
|
super().__init__(boxes, settings)
|
||||||
self.top = top
|
self.top = top
|
||||||
self.angled = angled
|
self.angled = angled
|
||||||
self.char = "uUvV"[bool(top) + 2 * bool(angled)]
|
self.char = "uUvV"[bool(top) + 2 * bool(angled)]
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.settings.thickness if self.top and self.angled else 0.0
|
return self.settings.thickness if self.top and self.angled else 0.0
|
||||||
|
|
||||||
def __poly(self):
|
def __poly(self):
|
||||||
|
@ -1864,7 +1862,7 @@ class CabinetHingeEdge(BaseEdge):
|
||||||
if hn == 1:
|
if hn == 1:
|
||||||
self.edge((l - width) / 2, tabs=2)
|
self.edge((l - width) / 2, tabs=2)
|
||||||
|
|
||||||
def parts(self, move=None):
|
def parts(self, move=None) -> None:
|
||||||
e, b = self.settings.eye, self.settings.bore
|
e, b = self.settings.eye, self.settings.bore
|
||||||
t = self.settings.thickness
|
t = self.settings.thickness
|
||||||
|
|
||||||
|
@ -1958,7 +1956,7 @@ Values:
|
||||||
"hole_width": 0
|
"hole_width": 0
|
||||||
})
|
})
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars=None, add=True):
|
def edgeObjects(self, boxes, chars=None, add: bool = True):
|
||||||
edges = [LidEdge(boxes, self),
|
edges = [LidEdge(boxes, self),
|
||||||
LidHoleEdge(boxes, self),
|
LidHoleEdge(boxes, self),
|
||||||
LidRight(boxes, self),
|
LidRight(boxes, self),
|
||||||
|
@ -1987,7 +1985,7 @@ class LidHoleEdge(FingerHoleEdge):
|
||||||
char = "L"
|
char = "L"
|
||||||
description = "Edge for slide on lid (box back)"
|
description = "Edge for slide on lid (box back)"
|
||||||
|
|
||||||
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
|
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw) -> None:
|
||||||
hole_width = self.settings.hole_width
|
hole_width = self.settings.hole_width
|
||||||
if hole_width > 0:
|
if hole_width > 0:
|
||||||
super().__call__((length - hole_width) / 2)
|
super().__call__((length - hole_width) / 2)
|
||||||
|
@ -2029,19 +2027,19 @@ class LidRight(BaseEdge):
|
||||||
p = list(reversed(p))
|
p = list(reversed(p))
|
||||||
self.polyline(*p)
|
self.polyline(*p)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
if self.rightside: # or self.settings.second_pin:
|
if self.rightside: # or self.settings.second_pin:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
else:
|
else:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
if not self.rightside: # or self.settings.second_pin:
|
if not self.rightside: # or self.settings.second_pin:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
else:
|
else:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
if not self.rightside: # and not self.settings.second_pin:
|
if not self.rightside: # and not self.settings.second_pin:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
else:
|
else:
|
||||||
|
@ -2093,13 +2091,13 @@ class LidSideRight(BaseEdge):
|
||||||
self.rectangularHole(holex, holey, 0.4 * t, t + 2 * s)
|
self.rectangularHole(holex, holey, 0.4 * t, t + 2 * s)
|
||||||
self.polyline(*p)
|
self.polyline(*p)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.boxes.thickness + self.settings.edge_width if self.rightside else -self.settings.play / 2
|
return self.boxes.thickness + self.settings.edge_width if self.rightside else -self.settings.play / 2
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return self.boxes.thickness + self.settings.edge_width if not self.rightside else -self.settings.play / 2
|
return self.boxes.thickness + self.settings.edge_width if not self.rightside else -self.settings.play / 2
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.boxes.thickness + self.settings.edge_width + self.settings.play / 2 if not self.rightside else 0.0
|
return self.boxes.thickness + self.settings.edge_width + self.settings.play / 2 if not self.rightside else 0.0
|
||||||
|
|
||||||
|
|
||||||
|
@ -2136,7 +2134,7 @@ Values:
|
||||||
"bottom_radius": 0.1,
|
"bottom_radius": 0.1,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="cC", add=True):
|
def edgeObjects(self, boxes, chars: str = "cC", add: bool = True):
|
||||||
edges = [ClickConnector(boxes, self),
|
edges = [ClickConnector(boxes, self),
|
||||||
ClickEdge(boxes, self)]
|
ClickEdge(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
@ -2146,7 +2144,7 @@ class ClickConnector(BaseEdge):
|
||||||
char = "c"
|
char = "c"
|
||||||
description = "Click on (bottom side)"
|
description = "Click on (bottom side)"
|
||||||
|
|
||||||
def hook(self, reverse=False):
|
def hook(self, reverse: bool = False) -> None:
|
||||||
t = self.settings.thickness
|
t = self.settings.thickness
|
||||||
a = self.settings.angle
|
a = self.settings.angle
|
||||||
d = self.settings.depth
|
d = self.settings.depth
|
||||||
|
@ -2197,7 +2195,7 @@ class ClickConnector(BaseEdge):
|
||||||
|
|
||||||
return s * d * c + 2 * r
|
return s * d * c + 2 * r
|
||||||
|
|
||||||
def finger(self, length):
|
def finger(self, length) -> None:
|
||||||
t = self.settings.thickness
|
t = self.settings.thickness
|
||||||
self.polyline(
|
self.polyline(
|
||||||
2 * t,
|
2 * t,
|
||||||
|
@ -2221,7 +2219,7 @@ class ClickConnector(BaseEdge):
|
||||||
self.hook(reverse=True)
|
self.hook(reverse=True)
|
||||||
self.edge(4 * t)
|
self.edge(4 * t)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 2 * self.settings.thickness
|
return 2 * self.settings.thickness
|
||||||
|
|
||||||
|
|
||||||
|
@ -2229,10 +2227,10 @@ class ClickEdge(ClickConnector):
|
||||||
char = "C"
|
char = "C"
|
||||||
description = "Click on (top)"
|
description = "Click on (top)"
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def __call__(self, length, **kw):
|
def __call__(self, length, **kw):
|
||||||
|
@ -2284,7 +2282,7 @@ Values:
|
||||||
"radius": 0.2,
|
"radius": 0.2,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="dD", add=True):
|
def edgeObjects(self, boxes, chars: str = "dD", add: bool = True):
|
||||||
edges = [DoveTailJoint(boxes, self),
|
edges = [DoveTailJoint(boxes, self),
|
||||||
DoveTailJointCounterPart(boxes, self)]
|
DoveTailJointCounterPart(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
@ -2333,7 +2331,7 @@ class DoveTailJoint(BaseEdge):
|
||||||
|
|
||||||
self.edge((s.size + leftover) / 2.0 + diffx - l1, tabs=1)
|
self.edge((s.size + leftover) / 2.0 + diffx - l1, tabs=1)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
""" """
|
""" """
|
||||||
return self.settings.depth
|
return self.settings.depth
|
||||||
|
|
||||||
|
@ -2345,7 +2343,7 @@ class DoveTailJointCounterPart(DoveTailJoint):
|
||||||
|
|
||||||
positive = False
|
positive = False
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
|
@ -2375,7 +2373,7 @@ Values:
|
||||||
"stretch": 1.05,
|
"stretch": 1.05,
|
||||||
}
|
}
|
||||||
|
|
||||||
def checkValues(self):
|
def checkValues(self) -> None:
|
||||||
if self.distance < 0.01:
|
if self.distance < 0.01:
|
||||||
raise ValueError("Flex Settings: distance parameter must be > 0.01mm")
|
raise ValueError("Flex Settings: distance parameter must be > 0.01mm")
|
||||||
if self.width < 0.1:
|
if self.width < 0.1:
|
||||||
|
@ -2480,7 +2478,7 @@ class RackEdge(BaseEdge):
|
||||||
self.moveTo(0, 0, 180)
|
self.moveTo(0, 0, 180)
|
||||||
self.boxes.spacing = s_tmp
|
self.boxes.spacing = s_tmp
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.dimension * 1.1
|
return self.settings.dimension * 1.1
|
||||||
|
|
||||||
|
|
||||||
|
@ -2510,7 +2508,7 @@ Values:
|
||||||
"outset": 0.,
|
"outset": 0.,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="t", add=True):
|
def edgeObjects(self, boxes, chars: str = "t", add: bool = True):
|
||||||
edges = [RoundedTriangleEdge(boxes, self),
|
edges = [RoundedTriangleEdge(boxes, self),
|
||||||
RoundedTriangleFingerHolesEdge(boxes, self)]
|
RoundedTriangleFingerHolesEdge(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
@ -2551,14 +2549,14 @@ class RoundedTriangleEdge(Edge):
|
||||||
else:
|
else:
|
||||||
self.corner(-90)
|
self.corner(-90)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.height + self.settings.radius
|
return self.settings.height + self.settings.radius
|
||||||
|
|
||||||
|
|
||||||
class RoundedTriangleFingerHolesEdge(RoundedTriangleEdge):
|
class RoundedTriangleFingerHolesEdge(RoundedTriangleEdge):
|
||||||
char = "T"
|
char = "T"
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.settings.thickness
|
return self.settings.thickness
|
||||||
|
|
||||||
def __call__(self, length, **kw):
|
def __call__(self, length, **kw):
|
||||||
|
@ -2596,7 +2594,7 @@ Values:
|
||||||
"outset": 1.,
|
"outset": 1.,
|
||||||
}
|
}
|
||||||
|
|
||||||
def edgeObjects(self, boxes, chars="yY", add=True):
|
def edgeObjects(self, boxes, chars: str = "yY", add: bool = True):
|
||||||
edges = [HandleEdge(boxes, self),
|
edges = [HandleEdge(boxes, self),
|
||||||
HandleHoleEdge(boxes, self)]
|
HandleHoleEdge(boxes, self)]
|
||||||
return self._edgeObjects(edges, boxes, chars, add)
|
return self._edgeObjects(edges, boxes, chars, add)
|
||||||
|
@ -2658,7 +2656,7 @@ class HandleEdge(Edge):
|
||||||
else:
|
else:
|
||||||
self.corner(-90)
|
self.corner(-90)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.height
|
return self.settings.height
|
||||||
|
|
||||||
|
|
||||||
|
@ -2672,5 +2670,5 @@ class HandleHoleEdge(HandleEdge):
|
||||||
self.fingerHolesAt(0, -0.5 * self.settings.thickness, length, 0)
|
self.fingerHolesAt(0, -0.5 * self.settings.thickness, length, 0)
|
||||||
super().__call__(length, **kw)
|
super().__call__(length, **kw)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.height + self.extra_height * self.settings.thickness
|
return self.settings.height + self.extra_height * self.settings.thickness
|
||||||
|
|
|
@ -799,11 +799,11 @@ class MoorBoxSideEdge(edges.BaseEdge):
|
||||||
else:
|
else:
|
||||||
self.polyline(length)
|
self.polyline(length)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.corner_height
|
return self.corner_height
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return 0 if self.lower_corner else self.corner_height
|
return 0.0 if self.lower_corner else self.corner_height
|
||||||
|
|
||||||
|
|
||||||
class MoorBoxHoleEdge(edges.BaseEdge):
|
class MoorBoxHoleEdge(edges.BaseEdge):
|
||||||
|
@ -851,11 +851,11 @@ class MoorBoxHoleEdge(edges.BaseEdge):
|
||||||
)
|
)
|
||||||
self.polyline(*full_polyline)
|
self.polyline(*full_polyline)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.corner_height
|
return self.corner_height
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return 0 if self.lower_corner else self.corner_height
|
return 0.0 if self.lower_corner else self.corner_height
|
||||||
|
|
||||||
|
|
||||||
class BedHeadEdge(edges.BaseEdge):
|
class BedHeadEdge(edges.BaseEdge):
|
||||||
|
|
|
@ -37,7 +37,7 @@ class BinFrontEdge(edges.BaseEdge):
|
||||||
else:
|
else:
|
||||||
self.corner(-45)
|
self.corner(-45)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return max(self.settings.sy) * self.settings.front
|
return max(self.settings.sy) * self.settings.front
|
||||||
|
|
||||||
class BinFrontSideEdge(BinFrontEdge):
|
class BinFrontSideEdge(BinFrontEdge):
|
||||||
|
|
|
@ -72,7 +72,7 @@ class BarrierEdge(edges.BaseEdge):
|
||||||
self.corner(90,self.thickness/2)
|
self.corner(90,self.thickness/2)
|
||||||
self.edge(0.2*length)
|
self.edge(0.2*length)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
|
|
||||||
class CanStorage(Boxes):
|
class CanStorage(Boxes):
|
||||||
|
|
|
@ -33,7 +33,7 @@ class CoinHolderSideEdge(edges.BaseEdge):
|
||||||
|
|
||||||
self.polyline(0, 90+a, a_l2, -90)
|
self.polyline(0, 90+a, a_l2, -90)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.coin_plate_x
|
return self.settings.coin_plate_x
|
||||||
|
|
||||||
class CoinDisplay(Boxes):
|
class CoinDisplay(Boxes):
|
||||||
|
|
|
@ -24,7 +24,7 @@ class DinRailEdge(edges.FingerHoleEdge):
|
||||||
self.width = width
|
self.width = width
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return 8 + self.settings.thickness
|
return 8 + self.settings.thickness
|
||||||
|
|
||||||
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
|
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
|
||||||
|
|
|
@ -50,11 +50,11 @@ class RoundedTriangle(edges.Edge):
|
||||||
self.edge(l)
|
self.edge(l)
|
||||||
self.corner(90 - angle, r)
|
self.corner(90 - angle, r)
|
||||||
|
|
||||||
def startAngle(self):
|
def startAngle(self) -> float:
|
||||||
return 90
|
return 90.0
|
||||||
|
|
||||||
def endAngle(self):
|
def endAngle(self) -> float:
|
||||||
return 90
|
return 90.0
|
||||||
|
|
||||||
|
|
||||||
class Lamp(Boxes):
|
class Lamp(Boxes):
|
||||||
|
|
|
@ -27,7 +27,7 @@ class USlotEdge(Edge):
|
||||||
self.polyline(0, 90, 0, (-90, r), l-2*d-2*r, (-90, r), 0, 90)
|
self.polyline(0, 90, 0, (-90, r), l-2*d-2*r, (-90, r), 0, 90)
|
||||||
self.edges["f"](d)
|
self.edges["f"](d)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.edges["f"].margin()
|
return self.edges["f"].margin()
|
||||||
|
|
||||||
class HalfStackableEdge(edges.StackableEdge):
|
class HalfStackableEdge(edges.StackableEdge):
|
||||||
|
@ -49,7 +49,7 @@ class HalfStackableEdge(edges.StackableEdge):
|
||||||
self.boxes.corner(-p * s.angle, r)
|
self.boxes.corner(-p * s.angle, r)
|
||||||
self.boxes.edge(length - 1 * s.width - 2 * l)
|
self.boxes.edge(length - 1 * s.width - 2 * l)
|
||||||
|
|
||||||
def endwidth(self):
|
def endwidth(self) -> float:
|
||||||
return self.settings.holedistance + self.settings.thickness
|
return self.settings.holedistance + self.settings.thickness
|
||||||
|
|
||||||
class NotesHolder(Boxes):
|
class NotesHolder(Boxes):
|
||||||
|
|
|
@ -265,7 +265,7 @@ class SideEdge(edges.BaseEdge):
|
||||||
self.polyline(0, -90, self.thickness, 90)
|
self.polyline(0, -90, self.thickness, 90)
|
||||||
self.edges["F"](tab_end)
|
self.edges["F"](tab_end)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.boxes.thickness
|
return self.boxes.thickness
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,5 +302,5 @@ class TabbedEdge(edges.BaseEdge):
|
||||||
)
|
)
|
||||||
self.edges["f"](tab_end)
|
self.edges["f"](tab_end)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.tab_depth + self.thickness
|
return self.tab_depth + self.thickness
|
||||||
|
|
|
@ -38,7 +38,7 @@ class SlotEdge(edges.Edge):
|
||||||
poly = [lo-1, (90, 1), d+t-1, -90, ls1+ls2, -90, d-t, (90, t)]
|
poly = [lo-1, (90, 1), d+t-1, -90, ls1+ls2, -90, d-t, (90, t)]
|
||||||
self.polyline(*(poly + [li-2*t] + list(reversed(poly))))
|
self.polyline(*(poly + [li-2*t] + list(reversed(poly))))
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.settings.thickness
|
return self.settings.thickness
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ from boxes import *
|
||||||
|
|
||||||
|
|
||||||
class MotorEdge(edges.BaseEdge):
|
class MotorEdge(edges.BaseEdge):
|
||||||
# def margin(self):
|
# def margin(self) -> float:
|
||||||
# return 30
|
# return 30.0
|
||||||
def __call__(self, l, **kw):
|
def __call__(self, l, **kw):
|
||||||
self.polyline(
|
self.polyline(
|
||||||
l - 165, 45,
|
l - 165, 45,
|
||||||
|
@ -30,15 +30,15 @@ class MotorEdge(edges.BaseEdge):
|
||||||
|
|
||||||
|
|
||||||
class OutsetEdge(edges.OutSetEdge):
|
class OutsetEdge(edges.OutSetEdge):
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return 20
|
return 20.0
|
||||||
|
|
||||||
|
|
||||||
class HangerEdge(edges.BaseEdge):
|
class HangerEdge(edges.BaseEdge):
|
||||||
char = "H"
|
char = "H"
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 40
|
return 40.0
|
||||||
|
|
||||||
def __call__(self, l, **kw):
|
def __call__(self, l, **kw):
|
||||||
self.fingerHolesAt(0, -0.5 * self.thickness, l, angle=0)
|
self.fingerHolesAt(0, -0.5 * self.thickness, l, angle=0)
|
||||||
|
@ -55,8 +55,8 @@ class HangerEdge(edges.BaseEdge):
|
||||||
|
|
||||||
|
|
||||||
class RollerEdge(edges.BaseEdge):
|
class RollerEdge(edges.BaseEdge):
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 20
|
return 20.0
|
||||||
|
|
||||||
def __call__(self, l, **kw):
|
def __call__(self, l, **kw):
|
||||||
m = 40 + 100
|
m = 40 + 100
|
||||||
|
@ -68,7 +68,7 @@ class RollerEdge(edges.BaseEdge):
|
||||||
|
|
||||||
|
|
||||||
class RollerEdge2(edges.BaseEdge):
|
class RollerEdge2(edges.BaseEdge):
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.thickness
|
return self.thickness
|
||||||
|
|
||||||
def __call__(self, l, **kw):
|
def __call__(self, l, **kw):
|
||||||
|
|
|
@ -29,7 +29,7 @@ class FrontEdge(edges.Edge):
|
||||||
self.corner(-a)
|
self.corner(-a)
|
||||||
self.moveTo(length)
|
self.moveTo(length)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.edge_width
|
return self.edge_width
|
||||||
|
|
||||||
class SpicesRack(Boxes):
|
class SpicesRack(Boxes):
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ShadyEdge(edges.BaseEdge):
|
||||||
if i < self.n-1:
|
if i < self.n-1:
|
||||||
self.edge(self.thickness)
|
self.edge(self.thickness)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.shades
|
return self.shades
|
||||||
|
|
||||||
class TrafficLight(Boxes): # change class name here and below
|
class TrafficLight(Boxes): # change class name here and below
|
||||||
|
|
|
@ -19,7 +19,7 @@ from boxes import *
|
||||||
class CornerEdge(edges.Edge):
|
class CornerEdge(edges.Edge):
|
||||||
char = "C"
|
char = "C"
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.boxes.thickness * math.tan(math.radians(90-22.5))
|
return self.boxes.thickness * math.tan(math.radians(90-22.5))
|
||||||
|
|
||||||
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
|
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
|
||||||
|
|
|
@ -34,7 +34,7 @@ class PinEdge(edges.BaseEdge):
|
||||||
s+=inc
|
s+=inc
|
||||||
self.polyline(*pin, s/2-w2-inc/4)
|
self.polyline(*pin, s/2-w2-inc/4)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.thickness+self.settings.pinlength
|
return self.settings.thickness+self.settings.pinlength
|
||||||
|
|
||||||
class WallPinRow(_WallMountedBox):
|
class WallPinRow(_WallMountedBox):
|
||||||
|
|
|
@ -33,10 +33,10 @@ class EyeEdge(boxes.edges.FingerHoleEdge):
|
||||||
angle = math.degrees(a)
|
angle = math.degrees(a)
|
||||||
self.polyline(0, -angle, l, (2*angle, r), l, -angle, 0)
|
self.polyline(0, -angle, l, (2*angle, r), l, -angle, 0)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.fingerHoles.settings.thickness
|
return self.fingerHoles.settings.thickness
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.servo.hinge_depth() + self.fingerHoles.settings.thickness + self.servo.servo_axle * 2
|
return self.servo.hinge_depth() + self.fingerHoles.settings.thickness + self.servo.servo_axle * 2
|
||||||
|
|
||||||
def buildEdges(boxes, servo, chars="mMnN"):
|
def buildEdges(boxes, servo, chars="mMnN"):
|
||||||
|
|
|
@ -86,7 +86,7 @@ class WallJoinedEdge(WallEdge):
|
||||||
self.edges["f"](length)
|
self.edges["f"](length)
|
||||||
self.step(t)
|
self.step(t)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
return self.settings.thickness
|
return self.settings.thickness
|
||||||
|
|
||||||
class WallBackEdge(WallEdge):
|
class WallBackEdge(WallEdge):
|
||||||
|
@ -100,7 +100,7 @@ class WallBackEdge(WallEdge):
|
||||||
self.edges["F"](length)
|
self.edges["F"](length)
|
||||||
self.step(-t)
|
self.step(-t)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.thickness
|
return self.settings.thickness
|
||||||
|
|
||||||
class WallHoles(WallEdge):
|
class WallHoles(WallEdge):
|
||||||
|
@ -151,11 +151,11 @@ class WallHoleEdge(WallHoles):
|
||||||
px, dist, length, angle)
|
px, dist, length, angle)
|
||||||
self.edge(length, tabs=2)
|
self.edge(length, tabs=2)
|
||||||
|
|
||||||
def startwidth(self):
|
def startwidth(self) -> float:
|
||||||
""" """
|
""" """
|
||||||
return self.wallHoles.settings.edge_width + self.settings.thickness
|
return self.wallHoles.settings.edge_width + self.settings.thickness
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
class WallSettings(Settings):
|
class WallSettings(Settings):
|
||||||
|
@ -257,7 +257,7 @@ class SlatWallEdge(WallEdge):
|
||||||
poly = reversed(poly)
|
poly = reversed(poly)
|
||||||
self.polyline(*poly)
|
self.polyline(*poly)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.hook_depth + self.settings.hook_distance
|
return self.settings.hook_depth + self.settings.hook_distance
|
||||||
|
|
||||||
class SlatWallSettings(WallSettings):
|
class SlatWallSettings(WallSettings):
|
||||||
|
@ -332,7 +332,7 @@ class DinRailEdge(WallEdge):
|
||||||
poly = reversed(poly)
|
poly = reversed(poly)
|
||||||
self.polyline(*poly)
|
self.polyline(*poly)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.depth
|
return self.settings.depth
|
||||||
|
|
||||||
class DinRailSettings(WallSettings):
|
class DinRailSettings(WallSettings):
|
||||||
|
@ -409,7 +409,7 @@ class FrenchCleatEdge(WallEdge):
|
||||||
poly = reversed(poly)
|
poly = reversed(poly)
|
||||||
self.polyline(*poly)
|
self.polyline(*poly)
|
||||||
|
|
||||||
def margin(self):
|
def margin(self) -> float:
|
||||||
return self.settings.depth
|
return self.settings.depth
|
||||||
|
|
||||||
class FrenchCleatSettings(WallSettings):
|
class FrenchCleatSettings(WallSettings):
|
||||||
|
|
Loading…
Reference in New Issue