assign_footprint
Assign footprints to placed symbols, as CvPcb ("Assign Footprints") of KiCad 10 does it when it saves.
Instructions
Assign footprints to placed symbols, as CvPcb ("Assign Footprints") of KiCad 10 does it when it saves.
The tool writes the footprint into the Footprint field of each unit of the reference, in the symbol, not in a variant. A variant with a Footprint of its own keeps it (the tool gives a warning; set_symbol_fields with the variant changes it). When the old footprint is empty and the field is visible, the field becomes hidden, as the save of CvPcb does ("Footprint field visible" in the table), also when the footprint stays empty. CvPcb hides such a field in each symbol of the netlist; the tool changes only the references of the call. An empty footprint removes the footprint.
The tool checks each footprint as CvPcb has it:
The footprint must be in a library that KiCad loads (the global and the project footprint library tables, an enabled row of the type "KiCad"), with the same case: else an error.
The footprint filters of the symbol (anchored wildcards, with no difference of case; a filter with ":" compares ":") and the pin count (the pins of the symbol against the pads of the footprint) give a warning when they do not match. CvPcb then does not show the footprint in that filtered list. The tool still writes the footprint.
The tool gets the pin count and the filters from the netlist of kicad-cli (the netlist that CvPcb reads). It refuses a reference that the netlist does not have (a symbol that is excluded from the board, or in a sheet that is excluded from the board), a power symbol (a reference that starts with "#"), a reference that is not annotated (U?), a duplicate reference, a symbol with no Footprint field, a Footprint field with a text variable (KiCad compares the resolved text), a footprint ID with no library name, and a library of an other type than "KiCad". With kicad-cli 10.0.0 to 10.0.6, a project with more than one top-level sheet is an error.
A symbol in a sheet that the hierarchy uses more than one time has one Footprint field for all its references (U201 and U301): give the same footprint for each of these references. CvPcb changes all of them; the tool refuses a call that gives only one.
The tool checks all assignments 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. A schematic file of the project with an older version than the installed KiCad writes is an error: the user converts it in KiCad first. 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>",
"assignments": "<assignments>"
},
"name": "assign_footprint"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignments | Yes | One item for each reference: the reference and the footprint ("<library>:<footprint>", or empty to remove it). | |
| schematic_path | Yes | A .kicad_sch file of the project. The tool finds the references in the full project. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |