"""Hexagon socket head cap screw with low head, DIN 7984, M3 to M12, any length. Envelope model for assemblies: cylindrical low head (diameter dk max, height k max), hexagon socket (key size s, depth t min) 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. """ from steve import Model size = "M5" # Thread size length = 12 # mm Nominal length (under the head) material = "steel" # Material # DIN 7984:2009-06, Tabelle 1, pp. 6-7 (https://tdm-neva.ru/upload/screws/din-7984.pdf; also # https://fasten.it/en/Norms/Norm/DIN%207984). size: (thread d, head diameter dk max, head height k max, hexagon socket s, # socket depth t min) DIMENSIONS = { "M3": (3.0, 5.5, 2.0, 2.0, 1.38), "M4": (4.0, 7.0, 2.8, 2.5, 2.18), "M5": (5.0, 8.5, 3.5, 3.0, 2.58), "M6": (6.0, 10.0, 4.0, 4.0, 2.88), "M8": (8.0, 13.0, 5.0, 5.0, 3.65), "M10": (10.0, 16.0, 6.0, 7.0, 4.35), "M12": (12.0, 18.0, 7.0, 8.0, 4.85), } # material choice: (STEVE material library id, appearance colour) MATERIALS = { "steel": ("steel-generic", "#2b2d30"), # property class 8.8, black oxide finish "stainless-a2": ("stainless-304", "#c9ccd0"), # ISO 3506-1 A2-70 "stainless-a4": ("stainless-316", "#c9ccd0"), # ISO 3506-1 A4-70 } d, dk, k, s, t = DIMENSIONS[size] material_id, colour = MATERIALS[material] model = Model() with model.sketch("head_sketch", on="XY", name="Head") as sk: sk.circle("head_circle", (0, 0), dk / 2) 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.plane("head_top", on="XY", offset=k, name="Head top") with model.sketch("socket_sketch", on="head_top", name="Hexagon socket") as sk: sk.polygon("hex", (0, 0), s / 2, 6, inscribed=False) model.extrude("socket", "socket_sketch", distance=-t, op="cut", name="Socket") model.material(material_id, color=colour) result = model.result()