Duplicating an existing footprint with pcbnew's Python API
Clone an already-placed footprint instead of recreating one from scratch, to quickly reproduce a component with its properties — with pcbnew or KiCad's IPC API.
When a footprint is already placed and correctly configured (footprint assignment, properties, symbol link), duplicating it is often faster than recreating one from scratch via FootprintLoad — handy for reproducing a connector or a calibration component in several spots.
Duplicating the footprint
Duplicate clones the object and all its pads; you then give it its own reference and position:
original = board.FindFootprintByReference("R1")
clone = original.Duplicate()
clone.SetReference("R2")
clone.SetPosition(VECTOR2I(FromMM(50), FromMM(20)))
board.Add(clone)Same idea on the IPC API side, with a duplication method on the board:
by_ref = {f.reference_field.text.value: f for f in board.get_footprints()}
original = by_ref["R1"]
clone = board.duplicate_item(original)
clone.reference_field.text.value = "R2"
clone.position = Vector2.from_mm(50, 20)
board.update_items(clone)Going further
Looping over a list of references and target positions turns Duplicate into the basis of a script that reproduces the same sub-circuit (a calibration footprint, a repeated connector) at several spots on the board without ever reopening the footprint library.