"""Heat / ultrasonic inserts for plastics, SPIROL Series 19 (metric), short and long: M2, M2.5, M3, M4. Envelope model: a cylinder of the overknurl diameter A and length L, axis along +Z, one end on the XY plane, centred on the origin, with the thread drawn as a bore at its nominal diameter (not modelled). The knurl bands and the pilot (lead -in) are not dimensioned in SPIROL's tables and are not modelled. """ from steve import Model size = "M3" # Thread variant = "short" # Length variant material = "brass" # Material # mm. SPIROL Series 19 short / long metric: (overknurl Ø A (Ref.), length L, recommended hole Ø), by thread SHORT = {"M2": (3.58, 3.18, 3.20), "M2.5": (4.62, 3.56, 3.99), "M3": (4.62, 3.56, 3.99), "M4": (6.25, 4.70, 5.61)} LONG = {"M2": (3.63, 3.99, 3.20), "M2.5": (4.75, 5.74, 3.99), "M3": (4.75, 5.74, 3.99), "M4": (6.38, 8.15, 5.61)} THREAD = {"M2": 2.0, "M2.5": 2.5, "M3": 3.0, "M4": 4.0} MATERIALS = {"brass": ("brass", "#c9a54a"), "aluminium": ("aluminum-generic", "#d4d7db")} A, L, hole = {"short": SHORT, "long": LONG}[variant][size] material_id, colour = MATERIALS[material] model = Model() with model.sketch("insert_sketch", on="XY", name="Insert") as sk: sk.circle("outside", (0, 0), A / 2) sk.circle("thread", (0, 0), THREAD[size] / 2) model.extrude("insert", "insert_sketch", distance=L, name="Insert") model.material(material_id, color=colour) result = model.result()