"""Hexagon head screw (fully threaded), ISO 4017 (DIN 933), M1.6 to M36, any length. Envelope model for assemblies: hexagon head (width across flats s, height k, sharp corners) and a plain shank at the nominal thread diameter d (the thread is not modelled). The head's bearing face is on the XY plane at the origin, the head above it, the shank along -Z; `length` is the nominal length l, measured from under the head. Two flats of the head are parallel to the X axis. """ from steve import Model size = "M6" # Thread size length = 20 # mm Nominal length (under the head) material = "steel" # Material # ISO 4017:2022, Tables 1-3 (official preview pp. 3-5: # https://cdn.standards.iteh.ai/samples/72585/1179998ddd594550a909d6e13c416f3e/ISO-4017-2022.pdf); the same values in # ISO 4017:2011 Table 1 and ISO 4017:2014 (M1.6-M6 seen). size: (thread d, width across flats s nominal, head height k nominal) DIMENSIONS = { "M1.6": (1.6, 3.2, 1.1), "M2": (2.0, 4.0, 1.4), "M2.5": (2.5, 5.0, 1.7), "M3": (3.0, 5.5, 2.0), "M4": (4.0, 7.0, 2.8), "M5": (5.0, 8.0, 3.5), "M6": (6.0, 10.0, 4.0), "M8": (8.0, 13.0, 5.3), "M10": (10.0, 16.0, 6.4), "M12": (12.0, 18.0, 7.5), "M14": (14.0, 21.0, 8.8), "M16": (16.0, 24.0, 10.0), "M20": (20.0, 30.0, 12.5), "M24": (24.0, 36.0, 15.0), "M30": (30.0, 46.0, 18.7), "M36": (36.0, 55.0, 22.5), } # material choice: (STEVE material library id, appearance colour) MATERIALS = { "steel": ("steel-generic", "#b4b8bd"), # property class 8.8, zinc plated "stainless-a2": ("stainless-304", "#c9ccd0"), # ISO 3506-1 A2-70 "stainless-a4": ("stainless-316", "#c9ccd0"), # ISO 3506-1 A4-70 / A4-80 } d, s, k = DIMENSIONS[size] material_id, colour = MATERIALS[material] model = Model() with model.sketch("head_sketch", on="XY", name="Head") as sk: sk.polygon("hex", (0, 0), s / 2, 6, inscribed=False) model.extrude("head", "head_sketch", distance=k, name="Head") with model.sketch("shank_sketch", on="XY", name="Shank") as sk: sk.circle("shank_circle", (0, 0), d / 2) model.extrude("shank", "shank_sketch", distance=-length, name="Shank") model.material(material_id, color=colour) result = model.result()