main
John Lauer Component record for mal216099702e3: files batch 2 8841b6d 1d ago
#!/usr/bin/env python3
"""KiCad symbol for MAL216099702E3: the graphics of KiCad's standard Device:C_Polarized (plates, outline-filled
negative plate, "+" sign; kicad-symbols master, CC-BY-SA 4.0 with the library exception), pins moved from +-3.81 to
+-5.08 so both pin ends sit on the 2.54 mm grid (pin length 2.794 -> 4.064, plates unchanged), pin 1 = + (anode),
pin 2 = - (cathode), passive, names "+" and "-" (hidden, as KiCad's polarized capacitor), numbers hidden. Fields carry
the orderable identity (MPN, manufacturer, distributor numbers, wiki link).
usage: make_symbol.py page.json out.kicad_sym"""
import sys, json
P = json.load(open(sys.argv[1])); C = P["component"]; D = C["distributor_links"]
N = "MAL216099702E3"
def prop(name, val, y, hide=True, just=None):
    j = f" (justify {just})" if just else ""
    return f'    (property "{name}" "{val}" (at {"2.54" if not hide else "0"} {y} 0) (effects (font (size 1.27 1.27)){j}{" hide" if hide else ""}))\n'
s = '(kicad_symbol_lib (version 20241209) (generator "adom_passive_symbol")\n'
s += f'  (symbol "{N}" (pin_numbers (hide yes)) (pin_names (offset 0.254) (hide yes)) (exclude_from_sim no) (in_bom yes) (on_board yes)\n'
s += prop("Reference", "C", 2.54, False, "left") + prop("Value", "100u 80V", -2.54, False, "left")
y = -7.62
for k, v in [("Footprint", "mal216099702e3:mal216099702e3"), ("Datasheet", C["datasheet"]),
             ("Description", "Aluminium electrolytic capacitor, polarized, 100 uF +-20 %, 80 V, 150 C, SMD 12.5 x 12.5 x 16 mm (Vishay 160 CLA, 4-pin)"),
             ("MPN", C["mpn"]), ("Manufacturer", C["manufacturer"]), ("Mouser", D["mouser"]["part"]), ("DigiKey", D["digikey"]["part"]),
             ("LCSC", ""), ("Adom Wiki", "https://wiki.adom.inc/adom/mal216099702e3"),
             ("ki_keywords", "capacitor electrolytic polarized aluminium SMD 150C 80V 100uF Vishay 160CLA MAL216099702E3")]:
    s += prop(k, v, round(y, 2)); y -= 2.54
s += f'''    (symbol "{N}_0_1"
      (rectangle (start -2.286 0.508) (end 2.286 1.016) (stroke (width 0) (type default)) (fill (type none)))
      (polyline (pts (xy -1.778 2.286) (xy -0.762 2.286)) (stroke (width 0) (type default)) (fill (type none)))
      (polyline (pts (xy -1.27 2.794) (xy -1.27 1.778)) (stroke (width 0) (type default)) (fill (type none)))
      (rectangle (start 2.286 -0.508) (end -2.286 -1.016) (stroke (width 0) (type default)) (fill (type outline)))
    )
    (symbol "{N}_1_1"
      (pin passive line (at 0 5.08 270) (length 4.064) (name "+" (effects (font (size 1.27 1.27)))) (number "1" (effects (font (size 1.27 1.27)))))
      (pin passive line (at 0 -5.08 90) (length 4.064) (name "-" (effects (font (size 1.27 1.27)))) (number "2" (effects (font (size 1.27 1.27)))))
    )
  )
)
'''
open(sys.argv[2], "w").write(s); print("OK", sys.argv[2])