Skip to content

Commit

Permalink
Moved hex standard data to global. Added imperial values.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Doe committed Dec 21, 2022
1 parent 814405f commit 063d079
Showing 1 changed file with 54 additions and 23 deletions.
77 changes: 54 additions & 23 deletions boxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,61 @@ def f(self, *args, **kw):
### Building blocks
#############################################################################

HexSizes = { # (nut width, nut height, shaft width)
"M1.6" : (3.2, 1.3, 1.6),
"M2" : (4, 1.6, 2),
"M2.5" : (5, 2.0, 2.5),
"M3" : (5.5, 2.4, 3),
"M4" : (7, 3.2, 4),
"M5" : (8, 4.7, 5),
"M6" : (10, 5.2, 6),
"M8" : (13.7, 6.8, 8),
"M10" : (16, 8.4, 10),
"M12" : (18, 10.8, 12),
"M14" : (21, 12.8, 14),
"M16" : (24, 14.8, 16),
"M20" : (30, 18.0, 20),
"M24" : (36, 21.5, 24),
"M30" : (46, 25.6, 30),
"M36" : (55, 31, 36),
"M42" : (65, 34, 42),
"M48" : (75, 38, 48),
"M56" : (85, 45, 56),
"M64" : (95, 51, 64),
"#0" : (0.156*25.4, 0.050*25.4, 0.060*25.4),
"#1" : (0.156*25.4, 0.050*25.4, 0.073*25.4),
"#2" : (0.188*25.4, 0.066*25.4, 0.086*25.4),
"#3" : (0.188*25.4, 0.066*25.4, 0.099*25.4),
"#4" : (0.250*25.4, 0.098*25.4, 0.112*25.4),
"#5" : (0.312*25.4, 0.114*25.4, 0.125*25.4),
"#6" : (0.312*25.4, 0.114*25.4, 0.138*25.4),
"#8" : (0.344*25.4, 0.130*25.4, 0.164*25.4),
"#10" : (0.375*25.4, 0.130*25.4, 0.190*25.4),
"#12" : (0.438*25.4, 0.161*25.4, 0.216*25.4),
"1/4" : (0.438*25.4, 0.226*25.4, 0.250*25.4),
"5/16" : (0.562*25.4, 0.273*25.4, (5/16 )*25.4),
"3/8" : (0.625*25.4, 0.337*25.4, (3/8 )*25.4),
"7/16" : (0.688*25.4, 0.385*25.4, (7/16 )*25.4),
"1/2" : (0.750*25.4, 0.448*25.4, (1/2 )*25.4),
"9/16" : (0.875*25.4, 0.496*25.4, (9/16 )*25.4),
"5/8" : (0.938*25.4, 0.559*25.4, (5/8 )*25.4),
"3/4" : (1.125*25.4, 0.665*25.4, (3/4 )*25.4),
"7/8" : (1.312*25.4, 0.776*25.4, (7/8 )*25.4),
"1" : (1.500*25.4, 0.887*25.4, (1 )*25.4),
"1-1/8": (1.688*25.4, 0.999*25.4, (1+1/8)*25.4),
"1-1/4": (1.875*25.4, 1.094*25.4, (1+1/4)*25.4),
"1-3/8": (2.062*25.4, 1.206*25.4, (1+3/8)*25.4),
"1-1/2": (2.250*25.4, 1.317*25.4, (1+1/2)*25.4),
"1-5/8": (2.438*25.4, 1.429*25.4, (1+5/8)*25.4),
"1-3/4": (2.625*25.4, 1.540*25.4, (1+3/4)*25.4),
"1-7/8": (2.813*25.4, 1.651*25.4, (1+7/8)*25.4),
"2" : (3.000*25.4, 1.763*25.4, (2 )*25.4),
"2-1/4": (3.375*25.4, 1.986*25.4, (2+1/4)*25.4),
"2-1/2": (3.750*25.4, 2.209*25.4, (2+1/2)*25.4),
}

class NutHole:
"""Draw a hex nut"""
sizes = {
"M1.6": (3.2, 1.3),
"M2": (4, 1.6),
"M2.5": (5, 2.0),
"M3": (5.5, 2.4),
"M4": (7, 3.2),
"M5": (8, 4.7),
"M6": (10, 5.2),
"M8": (13.7, 6.8),
"M10": (16, 8.4),
"M12": (18, 10.8),
"M14": (21, 12.8),
"M16": (24, 14.8),
"M20": (30, 18.0),
"M24": (36, 21.5),
"M30": (46, 25.6),
"M36": (55, 31),
"M42": (65, 34),
"M48": (75, 38),
"M56": (85, 45),
"M64": (95, 51),
}

def __init__(self, boxes, settings):
self.boxes = boxes
Expand All @@ -129,7 +160,7 @@ def __getattr__(self, name):
@restore
@holeCol
def __call__(self, size, x=0, y=0, angle=0):
size = self.sizes.get(size, (size,))[0]
size = HexSizes.get(size, (size,))[0]
side = size / 3 ** 0.5
self.boxes.moveTo(x, y, angle)
self.boxes.moveTo(-0.5 * side, 0.5 * size, angle)
Expand Down

0 comments on commit 063d079

Please sign in to comment.