lib_normalize_implementations
Clean up a SchLib by collapsing duplicate component models, clearing stale provenance, repairing footprint links, and optionally setting source library paths for embeddable footprints.
Instructions
Clean up every component's models in a SchLib for a self-contained package.
Whole-library sweep. Per component it: clears the component-level provenance (SourceLibraryName, TargetFileName); collapses duplicate models, keeping ONE per (model_type, model_name) IN PLACE so the kept model's parameters, MapAsString pin-map, and datafile link are all preserved; re-flags the survivor current if any duplicate was; optionally renames a model's name and its datafile entity via rename_map; and repairs any footprint (PCBLIB) left with no datafile link. It does NOT destroy and rebuild implementations, so nothing on a model is lost.
With source_library set, it also writes that value into the Location of every PCBLIB model's datafile link, turning a name-only library (footprints resolve but do not embed) into an embeddable one in the same pass. Existing Locations are only overwritten when source_library is given; they are never blanked. Get the exact string from a known-good model first (see lib_set_model_source).
Note: it preserves what is present; it cannot resurrect data a prior broken run already dropped. If a library was damaged by an earlier version, restore the backup and run this on it.
If you are also renaming footprint entities, run lib_rename_footprint on the PcbLib first, then pass the same {old: new} as rename_map so symbol and footprint stay matched.
Args: library_path: optional .SchLib path; defaults to the focused lib. rename_map: optional {old_model_name: new_model_name} applied to the kept model's name and matching datafile entity. dedupe_only: skip renames; only collapse duplicates + clear source. source_library: optional; when set, written into every PCBLIB model's datafile Location so footprints embed on compile. use_component_library: optional; sets the embed-vs-search flag on the models whose Location is written.
Returns: {"success": true, "components_touched": N, "duplicates_removed": N, "sources_cleared": N, "links_repaired": N, "sources_set": N}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rename_map | No | ||
| dedupe_only | No | ||
| library_path | No | ||
| source_library | No | ||
| use_component_library | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||