"""Socket set screw, inch series, ASME B18.3, #0 to 1/2 in, UNC and UNF, any length. Envelope model for assemblies: a plain cylinder at the basic major diameter D of ASME B1.1 (the thread and the point shape, e.g. a cup point, are not modelled) with a hexagon socket of nominal key size J in its top end, as deep as the standard's minimum key engagement for cup and flat point screws of that length (T_H min from L0 up; the short-length table below L0). The top face is on the XY plane at the origin and the screw points along -Z; `length` (inches) is the overall length. The model is in millimetres (1 in = 25.4 mm). """ from steve import Model size = "#10-32" # Thread (Unified, ASME B1.1) length = 0.25 # in Overall length material = "steel" # Material # Thread designation: nominal size THREADS = { "#0-80": "#0", "#1-64": "#1", "#1-72": "#1", "#2-56": "#2", "#2-64": "#2", "#3-48": "#3", "#3-56": "#3", "#4-40": "#4", "#4-48": "#4", "#5-40": "#5", "#5-44": "#5", "#6-32": "#6", "#6-40": "#6", "#8-32": "#8", "#8-36": "#8", "#10-24": "#10", "#10-32": "#10", "1/4-20": "1/4", "1/4-28": "1/4", "5/16-18": "5/16", "5/16-24": "5/16", "3/8-16": "3/8", "3/8-24": "3/8", "7/16-14": "7/16", "7/16-20": "7/16", "1/2-13": "1/2", "1/2-20": "1/2", } # Inches. D: basic major diameter (ASME B1.1; NBS Handbook H28 (1969) Table 2.7, # https://nvlpubs.nist.gov/nistpubs/Legacy/hb/nbshandbook28-1969p1.pdf; Holo-Krome Technical Manual 2015 Table 13). # J, T_H min, L0: ASME B18.3 hexagon socket set screws, cup point (ASME B18.3-2012 Table 14, # https://www.globalfastener.com/standards/detail_20314.html; same J and T_H in B18.3-2003 Table 5A, # https://www.fasten.it/en/norms/norm/asme_b18.3_table_5a, and Holo-Krome Table 13, p. 16-17 [PDF 24-25], # https://holo-krome.com/uploads/7/2/7/5/72754089/hk_consolidated_tech_manual_full_2015.pdf). # T_H applies to nominal lengths L0 and longer (note 3). # nominal: (D, J nominal key, T_H min key engagement, L0 shortest length for T_H, cup and flat point) DIMENSIONS = { "#0": (0.0600, 0.028, 0.050, 0.125), "#1": (0.0730, 0.035, 0.060, 0.125), "#2": (0.0860, 0.035, 0.060, 0.125), "#3": (0.0990, 0.050, 0.070, 0.1875), "#4": (0.1120, 0.050, 0.070, 0.1875), "#5": (0.1250, 0.0625, 0.080, 0.1875), "#6": (0.1380, 0.0625, 0.080, 0.1875), "#8": (0.1640, 0.078125, 0.090, 0.1875), "#10": (0.1900, 0.09375, 0.100, 0.1875), "1/4": (0.2500, 0.125, 0.125, 0.25), "5/16": (0.3125, 0.15625, 0.156, 0.3125), "3/8": (0.3750, 0.1875, 0.188, 0.375), "7/16": (0.4375, 0.21875, 0.219, 0.4375), "1/2": (0.5000, 0.25, 0.250, 0.5), } # Shorter lengths, cup and flat points: Holo-Krome Technical Manual 2015, Table 14 "Hexagon key engagements for short # length set screws" (p. 18 [PDF 26]). nominal: {nominal length L: T min key engagement}. The table prints lengths as # two-place decimals (Table 13 note 1): 0.06 = 1/16, 0.09 = 3/32, 0.13 = 1/8, 0.16 = 5/32, 0.19 = 3/16, 0.25, # 0.31 = 5/16, 0.38 = 3/8, 0.44 = 7/16. Other lengths shorter than L0 have no sourced key engagement. SHORT = { "#0": {0.0625: 0.030, 0.09375: 0.040}, "#1": {0.0625: 0.030, 0.09375: 0.040}, "#2": {0.0625: 0.030, 0.09375: 0.040}, "#3": {0.09375: 0.040, 0.125: 0.055}, "#4": {0.09375: 0.045, 0.125: 0.060}, "#5": {0.09375: 0.040, 0.125: 0.060}, "#6": {0.09375: 0.040, 0.125: 0.060, 0.15625: 0.070}, "#8": {0.125: 0.060, 0.15625: 0.070}, "#10": {0.125: 0.060}, "1/4": {0.1875: 0.090}, "5/16": {0.25: 0.125}, "3/8": {0.25: 0.110, 0.3125: 0.140}, "7/16": {0.375: 0.160}, "1/2": {0.375: 0.175, 0.4375: 0.215}, } # material choice: (STEVE material library id, appearance colour) MATERIALS = { "steel": ("steel-generic", "#2b2d30"), # alloy steel, black oxide "stainless-18-8": ("stainless-304", "#c9ccd0"), "stainless-316": ("stainless-316", "#c9ccd0"), } INCH = 25.4 nominal_size = THREADS[size] D, J, T_H, L0 = DIMENSIONS[nominal_size] if length >= L0 - 1e-9: T = T_H elif any(abs(length - L) < 1e-6 for L in SHORT[nominal_size]): T = next(v for L, v in SHORT[nominal_size].items() if abs(length - L) < 1e-6) else: raise ValueError(f"no sourced key engagement for a {size} set screw {length} in long: lengths from {L0} in, " f"or {', '.join(str(L) for L in SHORT[nominal_size])} in") d = D * INCH s = J * INCH overall = length * INCH depth = T * INCH material_id, colour = MATERIALS[material] model = Model() with model.sketch("body_sketch", on="XY", name="Body") as sk: sk.circle("body_circle", (0, 0), d / 2) model.extrude("body", "body_sketch", distance=-overall, name="Body") with model.sketch("socket_sketch", on="XY", name="Hexagon socket") as sk: sk.polygon("hex", (0, 0), s / 2, 6, inscribed=False) model.extrude("socket", "socket_sketch", distance=-depth, op="cut", name="Socket") model.material(material_id, color=colour) result = model.result()