copy_symbol_to_library
Copy a symbol into a library of the project table, as "Save As" of the symbol editor of KiCad 10 does.
Instructions
Copy a symbol into a library of the project table, as "Save As" of the symbol editor of KiCad 10 does.
To an other library, a derived symbol goes with its parents (KiCad copies the full parent chain; only the symbol gets the new name). flatten=True saves only the flattened symbol, as the "Flatten" check box. The Value gets the new name when it was equal to the old name.
The copy starts from the symbols as KiCad loads them: the text of a save of the library in kicad-cli (about 0.2 s, a cache keeps the last saves). Thus a library that KiCad did not save gives the texts of KiCad: no blanks at the ends of a mandatory field, the canonical field names ("value" is "Value"), "_1" for a second field of one name. The Value follows the new name also when the file has "value" or blanks at the ends of the old name. KiCad saves the library (kicad-cli), and a second save must give the same bytes.
The target must be a symbol library file of the project table in the version of the installed KiCad (else: upgrade_project_libraries first). KiCad must not have the project 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": {
"project_path": "<project_path>",
"lib_id": "<lib_id>",
"target_library": "<target_library>"
},
"name": "copy_symbol_to_library"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lib_id | Yes | The symbol, "<library>:<symbol>", for example "Device:R". | |
| flatten | No | True saves only the flattened symbol, with no parent. | |
| new_name | No | The new name. KiCad changes spaces to "_". Default: the old name. | |
| overwrite | No | True replaces the symbols with the same names in the target (KiCad: Overwrite / Overwrite All). False refuses them. | |
| project_path | Yes | The .kicad_pro file or the project folder. | |
| target_library | Yes | The nickname of the target in the project symbol table. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |