"""ISO 4032 hex nut. Envelope: hex prism with a plain bore at the thread's nominal diameter. It sits on the XY plane, centred on the origin. Material: property class 8 carbon steel (C35), zinc plated.""" from steve import Model size = "M3" # Thread size # size: (across flats s, height m) NUTS = { 'M2': (4.0, 1.6), 'M2.5': (5.0, 2.0), 'M3': (5.5, 2.4), 'M4': (7.0, 3.2), 'M5': (8.0, 4.7), 'M6': (10.0, 5.2), 'M8': (13.0, 6.8), 'M10': (16.0, 8.4), 'M12': (18.0, 10.8), } NOMINAL = { 'M2': 2.0, 'M2.5': 2.5, 'M3': 3.0, 'M4': 4.0, 'M5': 5.0, 'M6': 6.0, 'M8': 8.0, 'M10': 10.0, 'M12': 12.0, } s, m = NUTS[size] d = NOMINAL[size] model = Model() with model.sketch("nut_sketch", on="XY", name="Nut") as sk: sk.polygon("hex", (0, 0), s / 2, 6, inscribed=False) sk.circle("bore", (0, 0), d / 2) model.extrude("nut", "nut_sketch", distance=m) model.material("steel-1c35") # class 8 nut steel model.appearance(color="#c9d1d9", metalness=1.0, roughness=0.3) # clear zinc plating result = model.result()