"""Power molded chip inductor, Würth WE-PMCI sizes. Centred on the origin, sitting on the XY plane, length along X with the two end 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 = "201610" # WE-PMCI size code: length, width, height in tenths of a mm # size: (length, width, height, terminal length from each end), ranges (min, max), mm. Würth Elektronik WE-PMCI datasheets, page 1, Dimensions, one per # size (order code, case, version and date): 160808 74479262147 0603 001.001 2017-03-09; 201210 74479275222 0805 001.001 2017-03-09; 201610 74479276124 # 0806 002.000 2017-09-29; 252010 74479287222 1008 002.000 2017-09-29; 252012 74479288222 1008 003.000 2017-09-29; 322510 74479298222 1210 002.000 # 2017-09-29; 322512 74479299147 1210 002.000 2017-09-29. The height is drawn as a maximum only, written (value, value) and used as drawn. SIZES = { "160808": ((1.4, 1.8), (0.6, 1.0), (0.8, 0.8), (0.1, 0.5)), "201210": ((1.8, 2.2), (1.05, 1.45), (1.0, 1.0), (0.2, 0.8)), "201610": ((1.8, 2.2), (1.4, 1.8), (1.0, 1.0), (0.2, 0.8)), "252010": ((2.3, 2.7), (1.8, 2.2), (1.0, 1.0), (0.4, 0.8)), "252012": ((2.3, 2.7), (1.8, 2.2), (1.2, 1.2), (0.4, 0.8)), "322510": ((3.0, 3.4), (2.3, 2.7), (1.0, 1.0), (0.4, 0.8)), "322512": ((3.0, 3.4), (2.3, 2.7), (1.2, 1.2), (0.4, 0.8)), } INSET = 0.03 # how far the molded body between the terminals sits inside them: a proportion, for looks def mid(pair): return (pair[0] + pair[1]) / 2 L, W, H, E = SIZES[size] length, width, height, term = mid(L), mid(W), mid(H), mid(E) model = Model() with model.sketch("terms_sketch", on="XY", name="Terminals") as sk: sk.rect("term_left", (-length / 2, -width / 2), (-length / 2 + term, width / 2)) sk.rect("term_right", (length / 2 - term, -width / 2), (length / 2, width / 2)) model.extrude("terms", "terms_sketch", distance=height, name="Terminals") model.plane("body_plane", on="XY", offset=INSET, name="Body") with model.sketch("body_sketch", on="body_plane", name="Body") as sk: sk.rect("body_rect", (-length / 2 + term - 0.01, -width / 2 + INSET), (length / 2 - term + 0.01, width / 2 - INSET)) model.extrude("body", "body_sketch", distance=height - 2 * INSET, name="Body") model.material("pla", color="#3a3c40") result = model.result()