"""Shielded metal-alloy SMD power inductor, Würth WE-MAPI sizes. Centred on the origin, sitting on the XY plane, with the two bottom terminals at the -X and +X ends. Dimensions from the Würth datasheet for one order code of the size named by `size`; see the README.""" from steve import Model size = "3015" # WE-MAPI size code # size: (length, width, height max, terminal length, corner notch (depth, terminal width at the notch) or None), ranges (min, max), mm. Würth Elektronik # WE-MAPI datasheets, page 1, Dimensions, one per size (order code, revision, date): 2010 74438343012 001.002 2018-02-01; 2506 74438321010 001.002 # 2015-11-10; 2508 74438322022 001.002 2015-11-10; 2510 74438323010 001.002 2015-11-10; 2512 74438324010 001.001 2015-11-10; 3012 74438334047 001.002 # 2015-11-10; 3015 74438335330 001.002 2015-11-10; 3020 744383360047 001.001 2015-11-10; 4020 74438356033 001.000 2015-11-10; 4030 74438357022 001.000 # 2016-06-21. The 30xx terminal length is printed as 1.2 maximum only. SIZES = { "2010": ((1.8, 2.2), (1.4, 1.8), 1.0, (0.4, 0.8), None), "2506": ((2.3, 2.7), (1.8, 2.2), 0.6, (0.5, 0.9), None), "2508": ((2.3, 2.7), (1.8, 2.2), 0.8, (0.5, 0.9), None), "2510": ((2.3, 2.7), (1.8, 2.2), 1.0, (0.5, 0.9), None), "2512": ((2.3, 2.7), (1.8, 2.2), 1.2, (0.5, 0.9), None), "3012": ((2.8, 3.2), (2.8, 3.2), 1.2, (1.2, 1.2), None), "3015": ((2.8, 3.2), (2.8, 3.2), 1.5, (1.2, 1.2), None), "3020": ((2.8, 3.2), (2.8, 3.2), 2.0, (1.2, 1.2), None), "4020": ((3.9, 4.3), (3.9, 4.3), 2.1, (1.05, 1.45), ((0.25, 0.65), (2.2, 2.6))), "4030": ((3.9, 4.3), (3.9, 4.3), 3.1, (1.05, 1.45), ((0.25, 0.65), (2.2, 2.6))), } PAD_T = 0.1 # terminal thickness under the body: a proportion, for looks def mid(pair): return (pair[0] + pair[1]) / 2 L, W, top, T, notch = SIZES[size] length, width, term_l = mid(L), mid(W), mid(T) model = Model() model.plane("body_plane", on="XY", offset=PAD_T, name="Body") with model.sketch("body_sketch", on="body_plane", name="Body") as sk: sk.rect("body_rect", (-length / 2, -width / 2), (length / 2, width / 2)) model.extrude("body", "body_sketch", distance=top - PAD_T, name="Body") with model.sketch("terms_sketch", on="XY", name="Terminals") as sk: if notch is None: sk.rect("term_left", (-length / 2, -width / 2), (-length / 2 + term_l, width / 2)) sk.rect("term_right", (length / 2 - term_l, -width / 2), (length / 2, width / 2)) else: depth, narrow = mid(notch[0]), mid(notch[1]) # the outer `depth` of each terminal is `narrow` wide; the rest is the full width sk.rect("term_left", (-length / 2 + depth, -width / 2), (-length / 2 + term_l, width / 2)) sk.rect("term_right", (length / 2 - term_l, -width / 2), (length / 2 - depth, width / 2)) model.extrude("terms", "terms_sketch", distance=PAD_T + 0.05, name="Terminals") if notch is not None: with model.sketch("tips_sketch", on="XY", name="Terminals") as sk: sk.rect("tip_left", (-length / 2, -narrow / 2), (-length / 2 + depth + 0.05, narrow / 2)) sk.rect("tip_right", (length / 2 - depth - 0.05, -narrow / 2), (length / 2, narrow / 2)) model.extrude("tips", "tips_sketch", distance=PAD_T + 0.05, name="Terminals") model.material("pla", color="#3a3c40") result = model.result()