diff --git a/SKILL.md b/SKILL.md index 1b9a087..c3a72b6 100644 --- a/SKILL.md +++ b/SKILL.md @@ -376,6 +376,12 @@ optional if you'd rather hand-build the whole set in `params.json` — give at l `Description` written onto the symbol (and into the component's ComponentDescription field) is the exact one from the Excel, which was built to `references/description_format.md`. +Passing `--typeid` also fills the symbol's **`Type`** parameter with the component type for that +typeid — the taxonomy **Class** (e.g. `Resistor`, `Capacitor`, `Diode`, `Transistor`, +`Relay / Contactor`, `Inductor / Magnetics`, `Integrated Circuit (IC)`) — so the symbol +self-describes what kind of part it is. It's derived from the typeid (which came from the +datasheet), so it's set automatically; only an explicit `Type` in the Excel/params overrides it. + Deliver the resulting `.SchLib`; the engineer opens it in Altium once to confirm it loads, then **Saves to Server** with a revision note. The full parameter set, each value's source, the `params.json` shape (incl. the `remove` list), and the mini-stream size caveat are in diff --git a/assets/CHANGELOG.xlsx b/assets/CHANGELOG.xlsx index 721e445..822d231 100644 Binary files a/assets/CHANGELOG.xlsx and b/assets/CHANGELOG.xlsx differ diff --git a/scripts/schlib_write.py b/scripts/schlib_write.py index 835d377..d33937c 100644 --- a/scripts/schlib_write.py +++ b/scripts/schlib_write.py @@ -72,6 +72,20 @@ def template_param_names(template_path, typeid): if ws.cell(1, c).value and ws.cell(1, c).value not in NON_PARAM_COLS] +def component_type_for(typeid): + """The human-readable component TYPE for a typeid (e.g. 'Resistor', 'Capacitor', + 'Relay / Contactor', 'Inductor / Magnetics', 'Integrated Circuit (IC)') taken from the library + taxonomy's Class. Written into the symbol's `Type` parameter so the .SchLib self-describes what + kind of part it is. Returns None if the taxonomy can't be loaded or the typeid is unknown.""" + if not typeid: + return None + try: + import common + return (common.load_taxonomy().get(typeid.upper()) or {}).get("class") + except Exception: + return None + + def params_from_xlsx(xlsx_path, sheet=None): """Read the filled parameter values out of a per-part workbook (`.xlsx`) — row 1 is the headers, row 2 is the single data row this skill writes. Returns {header: value} for every @@ -302,6 +316,13 @@ def write_params(schlib, params_json, out, typeid=None, template=None, from_xlsx # consistent parameter set the template defines — not just whatever was hand-listed. typeid = typeid or params_json.get("typeid") template = template or params_json.get("template") + # Set the symbol's `Type` parameter to the component type for this typeid (Resistor, Capacitor, + # Relay / Contactor, ...), from the taxonomy Class — unless one was explicitly provided. This + # makes the symbol self-describe what kind of part it is. + if typeid: + ct = component_type_for(typeid) + if ct: + fields.setdefault("Type", ct) if typeid and template: for name in template_param_names(template, typeid): fields.setdefault(name, "")