update_symbols_from_library
Update placed symbols from their library symbols, as "Update Symbols from Library" of the schematic editor of KiCad 10 does it.
Instructions
Update placed symbols from their library symbols, as "Update Symbols from Library" of the schematic editor of KiCad 10 does it.
Each matching symbol gets the library symbol of its library ID (from the global and the project symbol library tables, flattened): the new shape and pins, the keywords and the footprint filters (always, as the dialog). The fields, the attributes and the alternate pins follow the options, with the defaults of the dialog. The library symbol is the text of a save in kicad-cli, as KiCad loads it: kicad-cli saves each library symbol with its parents one time (about 0.2 s), and again after a change of their text; a cache keeps the last 256 saves.
The pins follow the new library symbol (SCH_SYMBOL::UpdatePins): a pin keeps its UUID when the library symbol has its number; a new pin gets a new UUID, and a pin that the library symbol does not have goes. KiCad makes random UUIDs, and the order of a new pin comes from the memory: the tool uses the order of the placed pins in the file and of the library pins in the save of KiCad.
The fields of the update (fields): with no list, the dialog defaults: Footprint, Datasheet and Description, and each user field of the matching symbols and of their library symbols; not Reference and not Value. A private field is always updated. The position of a field (update_field_positions, and a new field) is the position of the symbol plus the position of the library field, rotated and mirrored as the symbol (SCH_FIELD::GetPosition). A user field of the library that the symbol does not have becomes a new field.
The tool refuses these updates:
A match with no symbol, or a field name that the dialog does not list.
A library ID that is not valid, or that the libraries do not have. A library symbol with fewer units than the symbol.
A symbol with no mandatory field (Reference, Value, Footprint, Datasheet or Description), with two fields of one name, or with a field or a library ID that the load changes (a field of the simulation of KiCad 7, "{slash}"): KiCad 10 never writes them (open and save the file in KiCad).
A symbol with fields_autoplaced and update_field_positions: KiCad places the fields with the sizes of its font, which the tool cannot measure.
A match that has only some instances of a symbol of a shared sheet.
A new reference for a sheet path with no instance in the file (KiCad makes the instance), or for two sheet paths that KiCad sorts by a hash.
A match that leaves an old copy of the library symbol with the same name and an other text in the file: a copy of an other symbol (add those symbols to the match), or a copy that no symbol uses. KiCad makes a copy with an other name when it finds the two symbols different. The tool compares only the texts, thus it can refuse a copy that KiCad finds equal.
"Update/reset pin name/number visibilities" changes nothing in the file: the update replaces the copy of the library symbol that holds it.
The tool checks all symbols and all files first, and writes no file when a check fails. It writes all files or no file. KiCad must not have the files open. The installed KiCad must be KiCad 10.0.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"schematic_path": "<schematic_path>"
},
"name": "update_symbols_from_library"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| match | No | "all" (each symbol), "reference" or "value" (pattern with "*" and "?", no case), or "lib_id" (pattern is "<library>:<symbol>"). | all |
| fields | No | The names of the fields to update, or none for the dialog defaults. The names of the user fields have case. | |
| options | No | The update options of the dialog; a missing option has the default of the dialog. | |
| pattern | No | The text of the match "reference", "value" or "lib_id". | |
| schematic_path | Yes | A .kicad_sch file of the project. The tool finds the symbols in the full project. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |