"""Würth Elektronik SMT steel spacers: WA-SMSI (internal thread), WA-SMST (plain bore), WA-SMSE (external thread) and WA-SMSR (reverse mount), from Würth's datasheets (one per order code, page 1). Round steel spacers, axis along +Z, centred on the origin; z = 0 is the shoulder that sits on the board: - WA-SMSI / WA-SMST: a body of diameter D from z = 0 to L, over a locating collar Dc x c (below z = 0), with the bore through (internal thread drawn at its nominal diameter; the thread is not modelled). The M1.6 variants: "blind" (thread from the top to depth Tli only), "closed" (no collar, blind thread), "pin" (no collar, a 0.8 x 0.5 pin under it, blind thread); - WA-SMSE: a body of diameter D from z = 0 to L with an M3 stud 6 long on top (at its nominal diameter; the thread and its undercut are not modelled) and a 0.8 x 0.5 pin underneath; - WA-SMSR: a flange D x 1.0 (z = 0 to 1) over a shank Dc, G long (below z = 0), bore through. Chamfers and the tape are not modelled. """ from steve import Model spacer = "SMSI-M3" # Series and size length = 3 # mm Length L (WA-SMSR: shank length G) thread_depth = 2 # mm Blind thread depth Tli (M1.6 blind, closed and pin variants only) # series: (kind, body D, collar or shank Dc (0 = none), collar height c, bore diameter (nominal thread or hole), bore) # bore: "through", "blind" (from the top, depth thread_depth). kind: "spacer", "stud" (WA-SMSE), "reverse" (WA-SMSR), # "pin" (a 0.8 x 0.5 pin instead of a collar). SPACERS = { "SMSI-M1.6": ("spacer", 3.3, 1.9, 0.7, 1.6, "through"), "SMSI-M1.6-blind": ("spacer", 3.3, 1.9, 0.7, 1.6, "blind"), "SMSI-M1.6-closed": ("spacer", 3.3, 0, 0, 1.6, "blind"), "SMSI-M1.6-pin": ("pin", 3.3, 0.8, 0.5, 1.6, "blind"), "SMSI-M2": ("spacer", 4.35, 2.8, 1.4, 2.0, "through"), "SMSI-M2.5": ("spacer", 5.1, 3.5, 1.4, 2.5, "through"), "SMSI-M3": ("spacer", 6.0, 4.2, 1.4, 3.0, "through"), "SMSI-M4": ("spacer", 8.2, 5.2, 1.4, 4.0, "through"), "SMST-2.25": ("spacer", 4.35, 2.8, 1.4, 2.25, "through"), "SMST-2.7": ("spacer", 5.1, 3.5, 1.4, 2.7, "through"), "SMST-3.3": ("spacer", 6.0, 4.2, 1.4, 3.3, "through"), "SMST-4.5": ("spacer", 8.2, 5.2, 1.4, 4.5, "through"), "SMSE-M3": ("stud", 6.0, 0.8, 0.5, 3.0, "stud"), "SMSR-M3": ("reverse", 6.0, 4.2, 1.0, 3.0, "through"), "SMSR-3.2": ("reverse", 6.0, 4.2, 1.0, 3.2, "through"), } STUD_LENGTH = 6.0 # WA-SMSE: M3 stud length kind, D, Dc, c, bore, bore_kind = SPACERS[spacer] model = Model() if kind == "reverse": model.cylinder("flange", D / 2, c, at=(0, 0, 0), name="Flange") model.cylinder("shank", Dc / 2, length, at=(0, 0, -length), op="join", name="Shank") model.cylinder("bore", bore / 2, length + c, at=(0, 0, -length), op="cut", name="Bore") else: model.cylinder("body", D / 2, length, at=(0, 0, 0), name="Body") if Dc > 0: model.cylinder("collar", Dc / 2, c, at=(0, 0, -c), op="join", name="Collar" if kind == "spacer" else "Pin") if kind == "stud": model.cylinder("stud", bore / 2, STUD_LENGTH, at=(0, 0, length), op="join", name="Stud") elif bore_kind == "through": model.cylinder("bore", bore / 2, length + c, at=(0, 0, -c), op="cut", name="Bore") else: if not 0 < thread_depth < length: raise ValueError("The blind thread must be shallower than the spacer.") model.cylinder("bore", bore / 2, thread_depth, at=(0, 0, length - thread_depth), op="cut", name="Thread") model.material("steel-generic", color="#c7c9cc") # steel, tin plated result = model.result()