Skip to content

Placing fields

berc place-fields PROJECT [--sheet NAME] [--write] [--set NAME=VALUE]

Each placed symbol whose shown fields overlap text, a body, a wire or the sheet edge (DRAW-9), or come closer than the drawing.clearance margins (DRAW-34), gets the first of these that clears them:

Only a rating that holds its kind's default may be hidden: a resistor's Package or Power, a capacitor's Package, Dielectric or Voltage. The defaults are the project's text variables DEFAULT_R_PACKAGE, DEFAULT_R_POWER, DEFAULT_C_PACKAGE, DEFAULT_C_DIELECTRIC and DEFAULT_C_VOLTAGE, which a drawing sheet can show; a rating without its variable is never hidden. Any other field, and any other value, stays shown, so a 250mW resistor or a C0G capacitor keeps its rating on the sheet. With drawing.fields.hide_defaults=always every shown rating at its default is hidden first, wherever it stands, and the fields left are then placed as below.

  1. Hideable rating fields that touch a power symbol, when nothing else overlaps the fields: those fields hidden, the column left where it is. Closeness alone is no reason to move a column that fits.
  2. A column: Reference, Value, then the rest top to bottom as they stood, justified toward the body, anchored on the field step 0.635 mm from the body, lines 2 mm apart whatever the text size, on the first side where it hits nothing and no wire runs through it, slid along the side (up to 5 mm) or set a little farther out (up to 2.5 mm) when it must. A horizontal two-pin part tries above, below, right, left, off the line its wires run along; every other part right, left, above, below. A one- or two-pin part (a test point, a resistor) tries every slide on a side before the next side; a column above or below is centred on the body. Fields that overlap nothing but stand more than 2 mm from their body are placed again the same way.
  3. A packed two-pin part (resistor, capacitor, diode, inductor, ferrite bead), whose centred column across its axis overlaps a neighbour's body on one side, or a body or settled fields on both, a horizontal one before any column: Reference and Value at the ends of the part, the other fields hidden; only when all of them are hideable. A horizontal part has them before and after its body on the line above its axis; a vertical one has them centred above and below its pins, only where that spot is clear.
  4. A column shortened by hiding its last hideable fields, the fewest that clear it.
  5. Else the column with the least overlap, or the fields stay when nothing is better.

Field text is always upright, never turned (DRAW-8). Bodies, wires, labels, power symbols and notes never move.

The margins follow drawing.clearance.spacing (--set drawing.clearance.spacing=sparse, here and in berc check):

Spacing Two parts' bodies, pins and fields keep between them
tight (default) only drawing.clearance.packed, 0.127 mm each: parts packed at grid pitch pass, overlaps still count
sparse their own margins, drawing.clearance.part and .text (2.54 mm body to body, 1.905 mm field to body)

Everything else (wires, labels, power symbols, notes, sheets) keeps its own margins in both.

Every layout follows one style, set by the drawing.fields settings (--set, or the project file):

Setting Default Meaning
drawing.fields.pitch 2 mm baseline-to-baseline distance between the lines of a column
drawing.fields.body_gap 0.635 mm space between a column (or a packed part's Reference and Value) and the body and pins
drawing.fields.step 0.25 mm grid the anchors are placed on, and the step a column slides or moves out by
drawing.fields.gap_max 2 mm fields farther than this from their body are placed again
drawing.fields.ends_raise 1.27 mm how far above a horizontal packed part's pin line its Reference and Value sit
drawing.fields.hide_defaults in_the_way in_the_way: a default rating is hidden only where the fields need room; always: wherever it is shown

Fields that overlap nothing are left alone when they follow the style or stand in some other arrangement. A column (lines on one anchor line, one justification, on one side of the body) or a packed part's ends off the style, by pitch, body gap, grid or a column slid off the middle of its side, is placed again in the style: a one- or two-pin part's on the first of its sides that fits, any other part's on the same side when it fits there next to the body, else the first side where it does, and only where that conflicts no more than where it stands. One run evens out the columns of a sheet; a second finds nothing to do.

The default is a dry run: each symbol with its layout, the fields it hides and what still overlaps (DRAW-9) or is too close (DRAW-34) once the whole sheet is placed, then both counts before and after (the edited files read again). --write edits the .kicad_sch files in place: only the moved fields' (at ...) and justify change, hidden fields get (hide yes), and their symbols lose (fields_autoplaced yes) so KiCad keeps the new places. Close the schematic in KiCad first. PROJECT is a directory or a .kicad_pro as for berc check; --sheet takes a sheet's name or file.