"""Clearance hole for a metric bolt or screw, as a cylinder to cut with: ISO 273 fine, medium and coarse series, at the low, middle or high end of its H tolerance. Axis along Z, the top face on the XY plane, the cylinder running down for the depth. Dimensions in the README.""" from steve import Model thread = "M3" # Thread fit = "normal" # close (ISO 273 fine, H12), normal (medium, H13) or loose (coarse, H14) tolerance = "mean" # min, mean or max of the hole's tolerance depth = 10 # mm Depth # thread: (fine, medium, coarse) clearance hole d_h in mm. ISO 273:1979, Section 2, Dimensions, table (official preview p. 1, # https://cdn.standards.iteh.ai/samples/4183/1a8db2e6de054d2e9bed7d40be64d6e1/ISO-273-1979.pdf). Tolerance fields given there for information: fine H12, # medium H13, coarse H14. HOLES = { "M1.6": (1.7, 1.8, 2), "M2": (2.2, 2.4, 2.6), "M2.5": (2.7, 2.9, 3.1), "M3": (3.2, 3.4, 3.6), "M4": (4.3, 4.5, 4.8), "M5": (5.3, 5.5, 5.8), "M6": (6.4, 6.6, 7), "M8": (8.4, 9, 10), "M10": (10.5, 11, 12), "M12": (13, 13.5, 14.5), "M14": (15, 15.5, 16.5), "M16": (17, 17.5, 18.5), "M20": (21, 22, 24), "M24": (25, 26, 28), "M30": (31, 33, 35), "M36": (37, 39, 42), "M42": (43, 45, 48), "M48": (50, 52, 56), "M56": (58, 62, 66), "M64": (66, 70, 74), "M72": (74, 78, 82), "M80": (82, 86, 91), "M90": (93, 96, 101), "M100": (104, 107, 112), } # size range upper bound in mm: (IT12, IT13, IT14) in micrometres. ISO 286-1 standard tolerance grades, as reproduced in ELESA+GANTER Technical Data 10.8, # DIN ISO 286 ISO-Fundamental tolerances (2018), https://www.elesa-ganter.in/siteassets/technical/DIN_ISO_286_ISO_Fundamental_Tolerances_EN.pdf GRADES = {3: (100, 140, 250), 6: (120, 180, 300), 10: (150, 220, 360), 18: (180, 270, 430), 30: (210, 330, 520), 50: (250, 390, 620), 80: (300, 460, 740), 120: (350, 540, 870)} column = {"close": 0, "normal": 1, "loose": 2}[fit] nominal = HOLES[thread][column] grade = next(GRADES[bound] for bound in sorted(GRADES) if nominal <= bound)[column] / 1000 diameter = nominal + {"min": 0, "mean": grade / 2, "max": grade}[tolerance] # an H hole: lower deviation 0, upper deviation the grade model = Model() with model.sketch("hole_sketch", on="XY", name="Hole") as sk: sk.circle("hole_circle", (0, 0), diameter / 2) model.extrude("hole", "hole_sketch", distance=-depth, name="Hole") result = model.result()