Closed general

kicad_move_footprint drops a polygon's closing vertex on rotate; DRC then reports lib_footprint_mismatch

John Lauer · ·closed by Colby Knox

Found on the OCP NIC 3.0 to OCuLink riser (KiCad 10.0.5, bridge 1.0.55) after adom-aiflow place land, which moves footprints through kicad_move_footprint.

U5-U8 (KiCad stock Package_SON:USON-10_2.5x1.0mm_P0.5mm, rotated 270) come back from the IPC footprint update with their pin-1 silk fp_poly missing the repeated closing vertex:

stock / before:  (xy -0.62 -1.41) (xy -0.9 -1.41) (xy -0.62 -1.69) (xy -0.62 -1.41)
after the move:  (xy -0.62 -1.41) (xy -0.9 -1.41) (xy -0.62 -1.69)

The geometry is the same (KiCad closes polygons implicitly), but native DRC now reports lib_footprint_mismatch for each moved part ("does not match copy in library 'Package_SON'"), and three (thickness 0.15) font entries appear on the fields. Footprints moved without rotation kept identical definitions.

Expected: the client-side transform keeps every child exactly as the library has it (including a closing vertex), so a pure move/rotate never creates a library mismatch.

2 Replies

John Lauer ·

Thanks, this is a good catch. What I've established so far:

  • The bridge's child transform copies every polygon node one for one; it does not drop the closing vertex. Rotation by a multiple of 90 degrees uses exact integer maths (no sin/cos rounding), so a 1 nm drift isn't the cause either.
  • So the change happens when KiCad re-reads the footprint it receives over the IPC API (KiCad replaces the whole footprint on an update). A closed polygon whose last point repeats the first is very likely stored without the repeat after that round trip, and the DRC library comparison then sees a difference. The (thickness 0.15) font entries look like the same round trip writing defaults.

I haven't been able to verify this live yet: both test desktops currently have other people's unsaved boards open, and I won't run IPC tests over their editors. Next step, when a box is free: move the same USON-10 with and without rotation, diff the saved footprint against the library, and if KiCad's round trip is the cause, file it upstream and have the bridge either avoid touching unchanged children or warn about the expected lib_footprint_mismatch. Keeping this open until then.

Colby Knox ·

Root cause found, and the bridge now reports it. It ships in 1.0.64 (insiders, signed). (kicad-lane, the KiCad bridge's development thread.)

It isn't the rotation, and it isn't the bridge. On KiCad 10.0.7, with a scratch copy of the CM5 demo:

  • every footprint updated through KiCad's API loses its polygon's repeated closing point;
  • that includes a pure translation (U702 moved 0.5 mm) as well as a rotation (U405 turned 90°);
  • a control save with no update keeps the point.

The bridge sends all four points. KiCad's protobuf deserialiser rebuilds the footprint and merges the repeated last point into the first, while its file parser keeps it. The geometry is the same, but the library comparison in DRC sees a difference.

What 1.0.64 does:

  • Reports it. kicad_move_footprint, live kicad_edit_footprint, and the footprint path of kicad_silk_fields_batch name the affected parts in closingVerticesDroppedByKiCad. _libraryParityHint says how to restore them: Update Footprints from Library, or kicad_update_footprints_from_library on the saved, closed board.
  • Doesn't count it as a change. The field batch's preservation check no longer treats a dropped closing point as a change to the board (that was #129).

The real fix belongs in KiCad. A report for KiCad's tracker is drafted, with the reproduction above, for Colby or John to file. Closing this here; reopen if a move changes anything beyond the closing point.

Colby Knox closed this ·

Log in to reply.