← Commit history

Publish 0.2.52

Colby Knox ·cc812e50ef ·1d ago ·parent b8943b0
1 file changed +4−8
tools/symbol_modes.py+4−8
@@ -11,9 +11,7 @@ A PIN's x,y is its BODY end, on the rectangle's edge (Altium's Pin.Location; the in its orientation). Until 2026-10-19 the outer end was written here, so every pin floated one pin length off the body with its name in the gap. Spec lines: META|libref|desc|designator  MODE|i|name  RECT|mode|x1|y1|x2|y2-PIN|mode|number|name|x|y|orient|len|hide|etype  LINE|mode|x1|y1|x2|y2-(etype: the KiCad pin type, input/output/bidirectional/tri_state/passive/power_in/power_out/...,-which the agent maps to Altium's pin electrical type)+PIN|mode|number|name|x|y|orient|len  LINE|mode|x1|y1|x2|y2 """  import sys as _sys@@ -42,7 +40,7 @@ def parse_pins(path):     for m in re.finditer(r'\(pin\s+(\w+)\s+(\w+)\s*\(at\s+([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)\)\s*\(length\s+([-\d.]+)\)', s):         tail = s[m.end():m.end() + 400]         name = re.search(r'\(name\s+"([^"]*)"', tail); num = re.search(r'\(number\s+"([^"]*)"', tail)-        pins.append({"num": num.group(1), "name": name.group(1), "etype": m.group(1)})+        pins.append({"num": num.group(1), "name": name.group(1)})     pins.sort(key=lambda p: int(p["num"]) if p["num"].isdigit() else 999)     return pins @@ -205,8 +203,7 @@ def native_lines(path):         dx, dy = {0: (1, 0), 90: (0, 1), 180: (-1, 0), 270: (0, -1)}.get(a, (1, 0))         orient = {0: "left", 90: "down", 180: "right", 270: "up"}.get(a, "left")         name = nm.group(1) if nm and nm.group(1) != "~" else ""-        et = re.match(r"\(pin\s+(\w+)", p)-        out.append("PIN|0|%s|%s|%d|%d|%s|%d|hide|" % (num.group(1) if num else "?", name, _mil(x + dx * L), _mil(y + dy * L), orient, _mil(L)) + (et.group(1) if et else ""))+        out.append("PIN|0|%s|%s|%d|%d|%s|%d|hide" % (num.group(1) if num else "?", name, _mil(x + dx * L), _mil(y + dy * L), orient, _mil(L)))     ref = re.search(r'\(property\s+"Reference"\s+"([A-Za-z]+)', s)     return (ref.group(1) if ref else "U"), g + out @@ -221,9 +218,8 @@ def build(pins, libref, desc, out):             body, pins_out = fn(pins, grouped, chip)             lines.append(f"MODE|{mode}|{name}{'-chip' if chip else ''}")             lines.append(f"RECT|{mode}|0|{-body['h']}|{body['w']}|0")-            et = {p["num"]: p.get("etype", "") for p in pins}             for _, num, pname, x, y, orient in pins_out:-                lines.append(f"PIN|{mode}|{num}|{pname}|{int(x)}|{int(y)}|{orient}|{PLEN}||{et.get(num, '')}")+                lines.append(f"PIN|{mode}|{num}|{pname}|{int(x)}|{int(y)}|{orient}|{PLEN}")             if chip:                 for (a, b, c, d) in chip_lines(body):                     lines.append(f"LINE|{mode}|{int(a)}|{int(b)}|{int(c)}|{int(d)}")