components module#

One walk of the design, feeding both fab files.

The BOM and the pick-and-place file are generated from the same records on purpose. JLCPCB only recognises a component that appears in both, and a designator in one and not the other is a documented upload failure, so the two files are built from one enumeration rather than from two walks that have to be kept in agreement.

DEFAULT_ORIENTATION = 0.0#

Correction applied to a component with no explicit orientation, in degrees.

Zero, deliberately. There is no single offset between JITX’s landpattern generators and the orientation JLCPCB takes as zero: measured against their placement preview on one board, an SOIC-8 needed -90, a 0603 LED needed +90, and a through-hole header needed something else again. A part’s zero is its tape-and-reel orientation, which is a property of the catalogue part rather than of the landpattern it is placed on, so no constant can be right for all of them.

A revision of this file did default to -90, from an observation that every part on one board needed turning 90 degrees clockwise. That observation was confounded: the board’s chip resistors are symmetric under a half turn and so look correct at either value, and its header turned out to be the wrong part. Correcting by a constant that is right for one package and 180 degrees wrong for another is worse than correcting nothing, because a wrong rotation that looks deliberate survives review.

So corrections are per part, via LCSCPart(orientation=…), and are measurements rather than guesses. The order sheet lists every part relying on this default so the placement preview has a checklist.

exception ExportError[source]#

Bases: Exception

A design the packet cannot describe.

class Part(designator, comment, footprint, lcsc, x, y, rotation, side, through_hole, footprint_guessed, orientation_default)[source]#

Bases: object

One component, as both fab files need it.

Parameters:
designator: str#
comment: str#
footprint: str#
lcsc: str | None#
x: float#
y: float#
rotation: float#
side: Side#
through_hole: bool#
footprint_guessed: bool#

The footprint came from a landpattern class name, which JLCPCB will most likely flag with a package-verification warning.

orientation_default: bool#

The orientation came from DEFAULT_ORIENTATION rather than from an LCSCPart that states one.

property layer: str#
class Inventory(parts, not_soldered)[source]#

Bases: object

Everything the packet says about the design’s components.

Parameters:
parts: list[Part]#

one row in each fab file.

Type:

Ordered, soldered and in the BOM

not_soldered: list[str]#

In the BOM sense but not placed. Omitted from both files and listed on the order sheet, because a sourced part with no placement lands in JLCPCB’s UI as an unselected part.

build(design, orientations=None)[source]#

Enumerate the design’s components into fab-file records.

Parameters:
  • design (RuntimeDesign) – the captured design to walk.

  • orientations (Mapping[str, float] | None) – recorded corrections keyed by LCSC C-number, from the lock file. These outrank LCSCPart(orientation=…); see _correction.

Return type:

Inventory

rotation(degrees, side)[source]#

The pick-and-place rotation for a placement, counter-clockwise.

Top side is the placement rotation. Bottom side is its negation, which is the conversion between JITX’s frame and the one JLCPCB’s recommended KiCad plugin emits: JITX composes a placement as R(r) . diag(sx, sy) and a bottom placement sets sx = -1, so a bottom part is R(r) . diag(-1, 1). The plugin’s frame mirrors about the other axis, R(t) . diag(1, -1), and diag(-1, 1) = R(180) . diag(1, -1), so t = r + 180. The plugin writes 180 - t, which is -r.

This is emphatically not 180 - r: the two differ by 180 degrees at every angle. See plans/jlcpcb-export-plan.md section 5.4.

Return type:

float

Parameters: