schlib_write: auto-fill the symbol's Type parameter with the component type (taxonomy Class) from the typeid

main
admin 2026-07-16 10:37:58 +00:00
parent c82d3d8381
commit 474d5830ac
No known key found for this signature in database
3 changed files with 27 additions and 0 deletions

View File

@ -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 `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`. 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 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 **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 `params.json` shape (incl. the `remove` list), and the mini-stream size caveat are in

Binary file not shown.

View File

@ -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] 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): def params_from_xlsx(xlsx_path, sheet=None):
"""Read the filled parameter values out of a per-part workbook (`<tag>.xlsx`) — row 1 is the """Read the filled parameter values out of a per-part workbook (`<tag>.xlsx`) — row 1 is the
headers, row 2 is the single data row this skill writes. Returns {header: value} for every 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. # consistent parameter set the template defines — not just whatever was hand-listed.
typeid = typeid or params_json.get("typeid") typeid = typeid or params_json.get("typeid")
template = template or params_json.get("template") 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: if typeid and template:
for name in template_param_names(template, typeid): for name in template_param_names(template, typeid):
fields.setdefault(name, "") fields.setdefault(name, "")