"""Slotted spring pin (heavy duty), ISO 8752 (DIN 1481), d 1 to 50 mm, any length. Free state (before fitting): a tube of outside diameter d1 max and wall s, both ends tapered over length a min to the end diameter d2 (the wall keeps its thickness through the taper), and an axial slot. ISO 8752 leaves the slot's width to the supplier (Table 2) but requires that the slot shall not fully close in the smallest permitted hole (clause 4: hole d H12, so its smallest size is d). The slot is drawn at that limit, pi * (d1 max - d) wide at the outside: the circumference a pin of d1 max gives up when pressed into a hole of diameter d. One end is on the XY plane at the origin, the pin along +Z, the slot at the +X side. """ import math from steve import Model diameter = 4 # mm Nominal diameter d length = 20 # mm Length l material = "spring-steel" # Material # ISO 8752:2009 Table 1, pp. 2-3 (official preview: https://cdn.standards.iteh.ai/samples/40658/df4caae79e6b4325b3bc70097ffa4274/ISO-8752-2009.pdf; # also https://fasten.it/en/Norms/Norm/DIN%20EN%20ISO%208752, 10-2009). # d: (d1 max before mounting, d2 before mounting (for reference), a min, s) DIMENSIONS = { 1: (1.3, 0.8, 0.15, 0.2), 1.5: (1.8, 1.1, 0.25, 0.3), 2: (2.4, 1.5, 0.35, 0.4), 2.5: (2.9, 1.8, 0.4, 0.5), 3: (3.5, 2.1, 0.5, 0.6), 3.5: (4.0, 2.3, 0.6, 0.75), 4: (4.6, 2.8, 0.65, 0.8), 4.5: (5.1, 2.9, 0.8, 1.0), 5: (5.6, 3.4, 0.9, 1.0), 6: (6.7, 4.0, 1.2, 1.2), 8: (8.8, 5.5, 1.6, 1.5), 10: (10.8, 6.5, 2.0, 2.0), 12: (12.8, 7.5, 2.0, 2.5), 13: (13.8, 8.5, 2.0, 2.5), 14: (14.8, 8.5, 2.0, 3.0), 16: (16.8, 10.5, 2.0, 3.0), 18: (18.9, 11.5, 2.0, 3.5), 20: (20.9, 12.5, 3.0, 4.0), 21: (21.9, 13.5, 3.0, 4.0), 25: (25.9, 15.5, 3.0, 5.0), 28: (28.9, 17.5, 3.0, 5.5), 30: (30.9, 18.5, 3.0, 6.0), 32: (32.9, 20.5, 3.0, 6.0), 35: (35.9, 21.5, 3.0, 7.0), 38: (38.9, 23.5, 4.0, 7.5), 40: (40.9, 25.5, 4.0, 7.5), 45: (45.9, 28.5, 4.0, 8.5), 50: (50.9, 31.5, 4.0, 9.5), } # material choice: (STEVE material library id, appearance colour) MATERIALS = { "spring-steel": ("steel-c60e", "#3a3c3f"), "stainless": ("stainless-420c", "#c9ccd0"), # martensitic stainless } if diameter not in DIMENSIONS: raise ValueError(f"ISO 8752 has no diameter {diameter} mm") d1, d2, a, s = DIMENSIONS[diameter] if length <= 2 * a: raise ValueError(f"length must be more than twice the taper length ({2 * a} mm)") outer, end = d1 / 2, d2 / 2 gap = math.pi * (d1 - diameter) # slot width at the outside, mm slot_angle = math.degrees(gap / outer) material_id, colour = MATERIALS[material] model = Model() with model.sketch("wall", on="XZ", name="Wall section") as sk: sk.polyline("outline", [(end - s, 0), (end, 0), (outer, a), (outer, length - a), (end, length), (end - s, length), (outer - s, length - a), (outer - s, a)]) model.revolve("pin", "wall", axis="Z", angle=360 - slot_angle, name="Pin") model.material(material_id, color=colour) result = model.result()