"""ISO 4017 (DIN 933) hex head screw, fully threaded. Envelope: hex head and plain shank. The head's bearing face is on the XY plane at the origin; the shank points down -Z.""" from steve import Model size = "M6" # Thread size length = 20 # mm Length under the head # size: (across flats s, head height k) HEADS = { 'M3': (5.5, 2.0), 'M4': (7.0, 2.8), 'M5': (8.0, 3.5), 'M6': (10.0, 4.0), 'M8': (13.0, 5.3), 'M10': (16.0, 6.4), 'M12': (18.0, 7.5), } NOMINAL = { 'M3': 3.0, 'M4': 4.0, 'M5': 5.0, 'M6': 6.0, 'M8': 8.0, 'M10': 10.0, 'M12': 12.0, } s, k = HEADS[size] d = NOMINAL[size] 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) with model.sketch("shank_sketch", on="XY", name="Shank") as sk: sk.circle("shank", (0, 0), d / 2) model.extrude("shank", "shank_sketch", distance=-length) result = model.result()