Routing
typeCAD includes an auto router that generates tracks between connected pins, and a fluent track builder for manual point-to-point routing.
route
Auto-route a net or a pin pair. Call it on the PCB instance with a net definition, or directly between pins; the returned tracks are included with create().
Example first
route-net.ts
import { PCB, Resistor } from '@typecad/pcb';
let typecad = new PCB('autoroute_example');
let r1 = new Resistor({ value: '1kohm', reference: 'R1' });
let r2 = new Resistor({ value: '1kohm', reference: 'R2' });
r1.pcb = { x: 10, y: 10, rotation: 0 };
r2.pcb = { x: 20, y: 10, rotation: 0 };
const signal_net = typecad.named('signal').net(r1.pin(1), r2.pin(1));
typecad.route(signal_net);
typecad.create(r1, r2);route (direct) await pcb.route({ from, to })
Route directly between pins without a named net:
route-direct.ts
let tracks = await typecad.route({
from: r1.pin(1),
to: r2.pin(1),
});
typecad.create(r1, r2, ...tracks);Options
| Option | Type | Units | Description |
|---|---|---|---|
| from / to | Pin or array of pins | required | The endpoints |
| width | number | mm | Trace width — calculated from powerInfo if omitted |
| layers | string[] | layer names | Restrict to specific copper layers (e.g. ['F.Cu', 'B.Cu']) |
| powerInfo | object | A / °C / µm | { current, maxTempRise, thickness } — automatic IPC-2221 trace width |
| waypoints | array | mm | Array of { x, y } points to guide the path |
| clearance | number | mm | Minimum clearance from other objects |
| gridResolution | number | mm | Search grid — lower values increase the search space and memory usage |
| impedance | object | Ω | { target, tolerance } — widens the trace to hit the target from the stackup |
route-config.ts
typecad.route(signal_net, {
gridResolution: 0.15,
debug: false,
});TrackBuilder
Fluent API for manual tracks — go point to point, using vias to transition between layers. Nets and connections aren't required: KiCAD connects any track that touches an element with a net.
Example first
manual-track.ts
import { PCB } from '@typecad/pcb';
let pcb = new PCB('typecad_docs');
let power_track = pcb
.track()
.powerInfo({ current: 1.0, maxTempRise: 10, thickness: 35 })
.from({ x: 100, y: 100 }, 'F.Cu', 0.2)
.to({ x: 110, y: 100 })
.via({ size: 0.8, drill: 0.4 })
.to({ x: 110, y: 120, layer: 'B.Cu' });
pcb.create(power_track);powerInfo .powerInfo({ current, maxTempRise, thickness })
| Parameter | Type | Units / values | Description |
|---|---|---|---|
| current | number | amps | Current the trace carries |
| maxTempRise | number | °C | Maximum wanted temperature rise (default 10) |
| thickness | number | microns | Copper thickness (35 = 1 oz) |
Automatic IPC-2221 trace width calculation.