Placement

Instead of hard-coding millimeter coordinates, use the placement helpers to position components relative to each other and the board edges. All gaps are measured courtyard edge to courtyard edge.

property

component.pcb

The position of a component on the board. Assign an object with x, y (mm from the origin) and optional rotation (degrees) — or any of the deferred placement values from pcb.board.

Example first

coordinates.ts
import { PCB, Component } from '@typecad/pcb';

let pcb = new PCB('typecad_docs');
pcb.outline(0, 0, 60, 45);

let u1 = new Component({ footprint: '...' });
u1.pcb = { x: 10, y: 20, rotation: 90 };
property

pcb.board

The board's physical dimensions, read live from the outlines you've defined. Usable before or after pcb.outline() — values follow the final outline. Placement values are live and order-independent: every deferred expression is re-resolved at create() against final positions.

Example first

board-bounds.ts
let u1 = new Component({ footprint: '...' });
u1.pcb = { x: b.center.x, y: b.center.y };   // center of the board

BoardBounds

PropertyDescription
center{ x, y } center point (centers the component's origin)
centered(){ x, y } placement values that center the component's occupied box — rotation- and origin-aware
left, right, top, bottomEdge coordinates in mm
width, heightBoard dimensions in mm
topLeft, topRight, bottomLeft, bottomRightCorner coordinates
fromLeft(n), fromRight(n), fromTop(n), fromBottom(n)A fixed distance in from that edge

Edge-relative placement

edge-relative.ts
import { PCB, Component } from '@typecad/pcb';

let pcb = new PCB('typecad_docs');
pcb.outline(0, 0, 60, 45);
const b = pcb.board;

let u1 = new Component({ footprint: '...' });
u1.pcb = { x: b.center.x, y: b.center.y };

Relational verbs

All placement lives on pcb.board — one namespace, no separate imports:

VerbDescription
below(c) / above(c)Place below/above component c
rightOf(c) / leftOf(c)Place right/left of component c
sameAs(c)Follow component c's position
.by(n)Override the default gap (mm)
.plus(n) / .minus(n)Live arithmetic on deferred values — returns a new deferred value
directional.ts
r2.pcb = { x: 10, y: pcb.board.below(r1).by(3) };   // 3 mm below r1's courtyard
mh1.pcb = { ...pcb.board.centered() };              // centered on the board

live arithmetic value.plus(n) / value.minus(n)

Placement values support live arithmetic — .plus(n)/.minus(n) return new deferred values, so expressions follow their source at create():

live.ts
let r2 = new Component({ footprint: '...' });
r2.pcb = {
  x: pcb.board.sameAs(r1).x.plus(2),   // follow r1 at create() time
  y: pcb.board.below(r1),
};
© 2026 typeCAD — code-defined electronics github