footprint module#
A catalogue footprint, fetched from LCSC and reduced to plain geometry.
EasyEDA is the source: easyeda2kicad fetches a part’s CAD data and parses it into its own intermediate model, and this module stops there. Nothing from easyeda2kicad.kicad is used, so none of the KiCad file format’s conventions reach a JITX design. See export/orientation.py, which does the same thing for pads alone.
Two things are normalized on the way in, and both are reflections rather than sign conventions, so getting either wrong yields a mirror image rather than a small error:
coordinates are made relative to the footprint’s own origin, which EasyEDA keeps in bbox, because everything it emits is in absolute canvas units;
the y axis is flipped, because EasyEDA’s points down and JITX’s points up.
Lengths are millimetres and angles are counter-clockwise degrees once here, which is what JITX wants. The result is JSON-serializable by design: it is what lcsc.lock.json records, so that a design builds the same landpattern on a machine that never reaches the network.
- DECORATIVE = frozenset({100, 101})#
Layers EasyEDA draws for its own editor and that mean nothing on a board.
LEAD_SHAPE is the outline of the part’s leads and COMPONENT_POLARITY the little circle it puts on pin 1; neither is fabricated, and both would end up as silkscreen if they were translated.
- exception FootprintError[source]#
Bases:
ExceptionA catalogue footprint that cannot be fetched or understood.
- class Segment(to, radii=None, rotation=0.0, large=False, clockwise=False)[source]#
Bases:
objectOne step of a path: a straight line, or an elliptical arc, to to.
- class Path(start, segments, closed=False)[source]#
Bases:
objectA run of segments from start, closed into a region or left open.
- class Pad(number, shape, x, y, width, height, rotation=0.0, layer=1, hole_radius=0.0, hole_length=0.0, outline=())[source]#
Bases:
objectOne pad of the catalogue footprint.
- Parameters:
number (
str) – pin number as EasyEDA states it. Not necessarily a number, and not necessarily unique: a part with two pads on one pin states the same number twice.shape (
str) – “RECT”, “ELLIPSE”, “OVAL” or “POLYGON”.x (
float) – centre, millimetres, y-up, relative to the footprint origin.y (
float) – centre, millimetres, y-up, relative to the footprint origin.width (
float) – x extent before rotation is applied.height (
float) – y extent before rotation is applied.rotation (
float) – counter-clockwise degrees.layer (
int) – EasyEDA layer id. TOP_COPPER is a surface-mount pad and MULTI_LAYER a through-hole one.hole_radius (
float) – drill radius, zero for a surface-mount pad.hole_length (
float) – drill length for a slot, zero for a round hole.outline (
tuple[tuple[float,float],...]) – the corners of a “POLYGON” pad, empty otherwise.
EasyEDA’s plating flag is not carried: it marks every surface-mount pad unplated, and it marks a USB-C receptacle’s shield tabs unplated as well, so it says nothing. A pad is somewhere a pin is connected and is therefore plated; an unplated hole is a Hole, which is what EasyEDA draws one as.
- class Via(x, y, diameter, hole_radius)[source]#
Bases:
objectA via drawn into the footprint itself, as a thermal pad’s often is.
- class Circle(layer, x, y, radius, width)[source]#
Bases:
objectA stroked circle on a graphical layer.
- class Region(layer, kind, path)[source]#
Bases:
objectA filled region on a graphical layer.
- Parameters:
- class Text(layer, x, y, size, width, rotation, string, kind='N', mirrored=False, visible=True)[source]#
Bases:
objectA text item on a graphical layer.
- Parameters:
kind (
str) – “N” for a plain note, “P” for the part’s prefix (reference designator) placeholder, “L” for its value placeholder.mirrored (
bool) – EasyEDA draws it mirrored, which a bottom-side item is.visible (
bool) – EasyEDA hides it in the editor.layer (int)
x (float)
y (float)
size (float)
width (float)
rotation (float)
string (str)
- class Footprint(name, pads=(), holes=(), vias=(), curves=(), circles=(), regions=(), texts=())[source]#
Bases:
objectA catalogue footprint in millimetres, y-up, about its own origin.
- Parameters:
name (
str) – EasyEDA’s own name for the package, such as “SOIC-8_L4.9-W3.9-P1.27-LS6.0-BL”.pads (
tuple[Pad,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.holes (
tuple[Hole,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.vias (
tuple[Via,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.curves (
tuple[Curve,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.circles (
tuple[Circle,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.regions (
tuple[Region,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.texts (
tuple[Text,...]) – the geometry, each item carrying the EasyEDA layer it was drawn on.
- json()[source]#
The record as it is written to lcsc.lock.json.
Empty collections are left out, so that the common footprint is a handful of pads and nothing else.
- static parse(entry)[source]#
Read back a record written by json.
- Raises:
FootprintError – the record is not one this understands. A hand edited lock file is the likely source, so the message says what was wrong rather than leaving a KeyError to surface.
- Return type:
- Parameters:
- from_easyeda(source)[source]#
Reduce an easyeda2kicad footprint to the normalized model.
Decorative layers are dropped; everything else is kept with the layer it was drawn on, so that deciding what a layer means is the landpattern’s job rather than this one’s.
- Return type:
- Parameters:
source (EeFootprint)
- fetch(partnumber)[source]#
Fetch a part’s catalogue footprint from LCSC.
This reaches the network. Callers are expected to have looked in lcsc.lock.json first and to record what comes back, so that a build that has already seen a part never gets here.
- Raises:
FootprintError – the part has no CAD data, or easyeda2kicad is not installed.
- Return type:
- Parameters:
partnumber (str)