# typeCAD - Complete Documentation --- ## Automate *Automate Your Hardware Design* ## Why Automate Hardware Design? Traditional hardware design is manual, error-prone, and time-consuming. **type**CAD brings the power of automation to electronic design, enabling you to **build smarter, faster, and more reliably** through code-driven workflows. ## Built-in Design Automation ### ⚡ **Electrical Rules Checking (ERC)** ```typescript import { runERC } from "@typecad/typecad"; // Run ERC programmatically let report = await runERC("./build/my_circuit.kicad_sch"); // Or use the CLI: typecad erc ``` Run ERC to validate your circuit against KiCAD's electrical rules. Catch connection errors, power mismatches, and pin type conflicts before they become hardware problems. ### 🔋 **Power-Aware Design Validation** ```typescript // Power-aware tracks with automatic width calculation let power_track = pcb.track() .powerInfo({ current: 2.0, maxTempRise: 10, thickness: 35 }) .from({ x: 100, y: 100 }, "F.Cu", 0.2) .to({ x: 110, y: 100 }); // Power-aware vias with current capacity checking let via = pcb.via({ at: { x: 10, y: 10 }, size: 0.8, drill: 0.4, powerInfo: { current: 1.5, maxTempRise: 5 } }); ``` **type**CAD automatically validates track widths, via sizes, and power delivery using IPC-2221 standards. No more manual calculations or thermal failures. ### 🎯 **Component Power Validation** ```typescript // Define power requirements let mcu = new Component({ /* ... */ }); mcu.pin(8, { powerInfo: { minimum_voltage: 3.0, maximum_voltage: 3.6, current: 0.25 }}); // Automatic power compatibility checking let power_supply = new Power({ power: mcu.pin(8), gnd: mcu.pin(4), voltage: 3.3, current: 1.0, direction: "output" }); ``` Automatically verify that power supplies can handle load requirements and voltage levels are compatible across your entire design. ## Custom Design Processing ### 📊 **Automated Documentation Generation** ```bash typecad doc docs/board.md build/board.kicad_pcb -o output.html ``` The `typecad doc` command converts markdown files and KiCAD PCBs into comprehensive documentation with layer exports and 3D renders. Perfect for: - **Assembly instructions** with layer-by-layer visuals - **Technical documentation** with automated BOM generation - **Manufacturing packages** with pick-and-place files - **Quality assurance** with automated test procedures See the [DocGen](/docs/docgen) documentation for full details. ### 🔧 **In-House Design Processing** Build custom automation workflows using **type**CAD's programmatic API: ```typescript // Custom BOM processing import { PCB } from "@typecad/typecad"; let pcb = new PCB("production_board"); // ... design your circuit ... // Generate custom manufacturing outputs pcb.create(); let bom = pcb.bom(); // Custom processing for your workflow processForManufacturing(bom); ``` Create specialized outputs for your manufacturing partners, cost analysis tools, or inventory management systems. ## AI Integration ### 🤖 **typeCAD MCP Server** ```bash npm install -g @typecad/typecad-mcp ``` The [typeCAD MCP Server](https://www.npmjs.com/package/@typecad/typecad-mcp) connects AI assistants directly to **type**CAD workflows: - **"Create a new sensor board project"** → Automatically scaffolds project structure - **"Add an ESP32-S3 with power regulation"** → Finds components and validates connections - **"Validate this design against the datasheet"** → Runs comprehensive checks - **"Generate assembly documentation"** → Creates manufacturing-ready outputs ### 🧠 **Intelligent Component Selection** AI assistants can: - **Analyze datasheets** and extract component specifications - **Suggest optimal components** based on design requirements - **Validate pin assignments** against manufacturer documentation - **Generate test procedures** for quality assurance ## Automation vs. Manual Comparison | Manual Design Process | typeCAD Automation | | ----------------------------------- | -------------------------------------- | | 🔍 Manual ERC checking | ⚡ Automatic electrical validation | | 📏 Calculate track widths by hand | 🧮 Power-aware routing with IPC-2221 | | 📋 Create BOMs manually | 📊 Generated documentation packages | | 🔌 Hunt for component datasheets | 🤖 AI-powered component analysis | | ⏰ Hours of validation work | ⚡ Instant design rule checking | ## The Automation Advantage Bringing automation to hardware design delivers the same transformative benefits that revolutionized software development: - **Reliability**: Catch errors before they reach hardware - **Speed**: Instant validation and documentation generation - **Consistency**: Standardized design rules across all projects - **Scalability**: Handle complex designs with confidence - **Integration**: Seamless CI/CD workflows for hardware [Get Started →](/getting-started) --- ## Code *Code as Schematic* ## Why Write Code Instead of Dragging Components? Traditional electrical design tools force you to click, drag, and manually wire components in a GUI. **type**CAD takes a different approach: **write TypeScript code to describe your circuit**, then build it into a KiCAD project. ## The Coding Experience ### � **Familiar Developer Tools** ```typescript import { PCB } from "@typecad/typecad"; import { Resistor, Capacitor } from "@typecad/passives/0603"; let typecad = new PCB("my_circuit"); let r1 = new Resistor({ value: "10kohm" }); let c1 = new Capacitor({ value: "100nF" }); ``` Use VS Code, TypeScript intellisense, and all your favorite developer tools. Get autocomplete for component properties, instant error checking, and refactoring support that actually understands your circuit. ### 🎯 **Declarative Circuit Description** ```typescript // Describe what you want, not how to draw it typecad.net(mcu.VCC, r1.pin(1), c1.pin(1)); // Power rail typecad.net(mcu.GND, r1.pin(2), c1.pin(2)); // Ground rail typecad.net(mcu.ADC0, r1.pin(2)); // Sensor input ``` Focus on the electrical connections and component relationships, not pixel-perfect wire routing. The code describes the circuit's behavior and intent clearly. ### 📐 **Parametric and Calculated Values** ```typescript // Let code do the math function ledResistor(vcc: number, vf: number, current: number) { return new Resistor({ value: `${(vcc - vf) / current}ohm` }); } let r_led = ledResistor(5.0, 2.1, 0.02); // 145Ω for 20mA LED ``` No more manual calculations or looking up resistor values. Define your requirements and let TypeScript calculate the exact component values you need. ## Code vs. GUI Comparison | GUI Schematic Tools | typeCAD Code | | ----------------------------------- | ------------------------------------- | | 🖱️ Click, drag, place components | ⌨️ `new Resistor({ value: "1kohm" })` | | 🔌 Manually draw wires | 🔗 `typecad.net(pin1, pin2)` | | 📏 Eyeball component values | 🧮 Calculate exact values with code | | 🔍 Hunt through component libraries | 📦 Import from npm packages | | 📋 Manual component lists | 📊 Generated BOMs and docs | ## The Developer Advantage Writing hardware as code brings the same benefits that transformed software development: - **Readability**: Circuit intent is clear from the code structure - **Maintainability**: Easy to modify and extend existing designs - **Consistency**: Standardized patterns across all your projects - **Speed**: Express complex circuits in just a few lines - **Precision**: Exact component values, no manual entry errors Ready to design hardware like you write software? [Get Started →](/getting-started) --- ## Docs 📗 typeCAD Documentation Programmatically create hardware designs with TypeScript and the npm ecosystem. {#each tracks as track} {track.title} {track.badge} {track.description} {#each track.links as link} {link.title} {/each} {/each} --- ## Ai *AI Notes* --- ## Autorouter *Auto Router* **type**CAD includes an auto router that generates tracks between connected pins. ## Usage Call `route()` on the `PCB` instance with a net definition: ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; 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); // [!code highlight] typecad.create(r1, r2); ``` You can also route directly between pins without a named net: ```ts let tracks = await typecad.route({ from: r1.pin(1), to: r2.pin(1), }); typecad.create(r1, r2, ...tracks); ``` ## Configuration The `route` method accepts an optional configuration object: ```ts typecad.route(signal_net, { gridResolution: 0.15, debug: false, }); ``` By default, the router uses a resolution derived from the trace width and clearance settings. Decreasing the resolution value increases the search space and memory usage but may help find paths in congested layouts. The router's fallback trace width and clearance come from the board's [design rules](/docs/board_layout#design-rules) (JLCPCB no-surcharge standard by default), or from the net's [net class](/docs/board_layout#net-classes) if it has been assigned one. Per-route `width` and `clearance` options override them for an individual trace. By default the router uses every copper layer the board declares, minus layers dedicated as [planes](/docs/board_layout#planes); pass `layers` to restrict a route (e.g. `layers: ['In3.Cu']`). Pass an `impedance` constraint (`impedance: { target: 50, tolerance: 5 }`) and the trace widens to hit the target computed from the board's [stackup](/docs/board_layout#stackup) — see [controlled impedance](/docs/board_layout#controlled-impedance). Router-placed vias follow the board's [via policy](/docs/board_layout#via-policy). ```ts let result = await pcb.autorouteBatch([ { from: mcu.SDA, to: sensor.SDA, name: 'SDA' }, { from: mcu.SCL, to: sensor.SCL, name: 'SCL' }, { from: power.pin, to: mcu.VCC, name: 'VCC' }, ], { rounds: 3, reorder: 'byDistance', }); pcb.create(); ``` It routes all items, then retries failed routes across multiple rounds with relaxed parameters and reordered priorities to negotiate congestion. Options: - _rounds_ — number of retry rounds (default: 3) - _reorder_ — reorder strategy: `'byDistance'` (default, longest first), `'reverse'`, or `'none'` - _relaxViaCostPerRound_ — reduce via cost each round (default: 5) - _increaseIterationsPerRound_ — add iterations each round (default: 25000) ## Length Matching > [!WARNING] > Length matching is **experimental**. The API may change. For differential pairs that require matched lengths, `LengthMatcher.apply()` extends shorter routes with sawtooth meanders: ```ts import { LengthMatcher } from '@typecad/typecad/routing'; LengthMatcher.apply(ctx, routeDetails, trackBuilders, { tolerance: 0.5, }); ``` Parameters: - _ctx_ — length match context (board context) - _routeDetails_ — array of `{ path, success }` from routing results - _trackBuilders_ — array of track builder arrays for each route - _config_ — tolerance in mm (number) or `{ tolerance, pattern, minStraightSegment, debug }` ## Debug Visualization Generate debug images of the routing grid to troubleshoot routing issues. Outputs PPM image files: ```ts import { DebugVisualizer } from '@typecad/typecad/routing'; DebugVisualizer.visualizeRouting( grid, obstacles, paths, 'debug_route', 'F.Cu', 1, ); ``` Parameters: - _grid_ — the routing grid - _obstacles_ — array of routing obstacles - _paths_ — array of routed paths - _filename_ — output filename (without extension), saves as `.ppm` - _layer_ — which layer to visualize - _cellSize_ — pixels per grid cell (default: 1) --> --- ## Board Layout *Board Layout* **type**CAD can help with board layout. Component locations can be set in code. ## PCB Coordinates Each `Component` has a `pcb` property that contains `{x, y, rotation, side}`. ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let pcb = new PCB('typecad_docs'); let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); r1.pcb = { x: 10, y: 10, rotation: 0 }; // [!code highlight] // Optionally place on the back side: // r1.pcb = { x: 10, y: 10, rotation: 0, side: 'back' }; pcb.create(); ``` `side` defaults to `'front'` and can be set to `'back'` to place a component on the bottom of the board. ## Relative 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**. All placement lives on `pcb.board` — bounds (`left`, `center`, `fromLeft()`, `centered()`), the relational verbs (`below(c)`, `above(c)`, `rightOf(c)`, `leftOf(c)`, `sameAs(c)`) — one namespace, no separate imports. Placement values support live arithmetic: `.plus(n)` / `.minus(n)` return new deferred values, so `pcb.board.sameAs(r1).x.plus(2)` follows r1 at `create()`. Placement values are live and order-independent: they re-read their source (component position or board outline) whenever they are resolved, and every deferred expression is re-resolved at `create()` against final positions. Assign positions in any order — `pcb.board` reads before the outline exists, `r2` below `r1` before `r1` moves — and the relationships still hold. Manually moving a component after assigning an expression freezes that axis: the manual value wins. The helpers can be assigned directly: `{ x: pcb.board.sameAs(mh1), y: pcb.board.below(mh1) }` (default gap) as well as `{ y: pcb.board.below(mh1).by(3) }`. ### `pcb.board` Get the board's physical dimensions from the outlines you've defined. Use it to place components at the center, or a fixed distance from any edge. `pcb.board` reads the outline live — usable before or after `pcb.outline()`; values follow the final outline. ```ts import { PCB } from '@typecad/typecad'; 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 }; // center of the board ``` `pcb.board` returns a `BoardBounds` object with these properties: | Property | Description | |----------|-------------| | `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: `u1.pcb = { ...pcb.board.centered() }` | | `left`, `right`, `top`, `bottom` | Edge coordinates in mm | | `width`, `height` | Board dimensions in mm | | `topLeft`, `topRight`, `bottomLeft`, `bottomRight` | Corner coordinates | ### Edge-relative placement with `fromLeft()`, `fromRight()`, `fromTop()`, `fromBottom()` Place a component a fixed distance from a board edge, accounting for the component's own footprint size: ```ts import { PCB, Component, board } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); pcb.outline(0, 0, 60, 45); const b = pcb.board; // Connector 5mm from the left edge (courtyard-to-edge) const j1 = new Component({ footprint: 'Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical', pcb: { x: b.fromLeft(5), y: b.center.y }, }); // Test point 1mm from the top-right corner (courtyard-to-edge) const tp1 = new Component({ footprint: 'TestPoint:TestPoint_Pad_D1.0mm', pcb: { x: b.fromRight(1), y: b.fromTop(1) }, }); pcb.create(j1, tp1); ``` The margin defaults to **2mm** if omitted: `b.fromLeft()` places the component 2mm from the left edge. ### Directional placement: `pcb.board.below()`, `pcb.board.above()`, `pcb.board.rightOf()`, `pcb.board.leftOf()` Place components relative to each other with a specified gap. Each returns a builder — call `.by(gap)` to set the edge-to-edge distance in mm (defaults to **2mm**). ```ts import { PCB, Component, below, above, rightOf, leftOf, sameAs, board } from '@typecad/typecad'; import { Resistor, Capacitor, LED } from '@typecad/passives/0603'; let pcb = new PCB('typecad_docs'); pcb.outline(0, 0, 60, 45); const b = pcb.board; // MCU at center let mcu = new Component({ footprint: 'Package_DFN_QFN:QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm' }); mcu.pcb = { x: b.center.x, y: b.center.y }; // Decoupling cap 3mm below MCU, aligned in X let c1 = new Capacitor({ value: '100nF', pcb: { x: pcb.board.sameAs(mcu), y: pcb.board.below(mcu).by(3), }}); // Pull-up resistor 2mm right of the cap, same row let r1 = new Resistor({ value: '10k', pcb: { x: pcb.board.rightOf(c1).by(2), y: pcb.board.sameAs(c1), }}); // LED 8mm above the MCU let led1 = new LED({ value: 'Red', pcb: { x: pcb.board.sameAs(mcu), y: pcb.board.above(mcu).by(8), }}); // Current-limiting resistor 4mm left of the LED let r2 = new Resistor({ value: '330', pcb: { x: pcb.board.leftOf(led1).by(4), y: pcb.board.sameAs(led1), }}); // Default 2mm gap let c2 = new Capacitor({ value: '10uF', pcb: { x: pcb.board.sameAs(r1), y: pcb.board.below(r1), }}); pcb.create(mcu, c1, r1, led1, r2, c2); ``` ### `pcb.board.sameAs()` Align a component's X or Y coordinate with another component: ```ts import { sameAs } from '@typecad/typecad'; // Same X as r1, custom Y let c1 = new Capacitor({ pcb: { x: pcb.board.sameAs(r1), y: 20 } }); // Same Y as r1, custom X let r2 = new Resistor({ pcb: { x: 30, y: pcb.board.sameAs(r1).y } }); ``` ## Component Text Positioning Each component has silkscreen and fabrication text labels (reference designator, value, and fab text). You can control their position and style using layout properties: | Property | Default Layer | Description | |----------|--------------|-------------| | `referenceLayout` | F.SilkS | Controls the reference designator text (e.g. "R1") | | `valueLayout` | F.Fab | Controls the value text (e.g. "1kohm") | | `fabLayout` | F.Fab | Controls fabrication text; `text` defaults to `${REFERENCE}` | All three accept an `ITextPositioning` object and can be set at construction or assigned later: ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let pcb = new PCB('text_layout'); let r1 = new Resistor({ value: '1kohm', reference: 'R1', referenceLayout: { x: 0, y: -1.5, rotation: 90, width: 0.8, height: 0.8 }, // [!code highlight] valueLayout: { x: 0, y: 1.5, width: 0.6, height: 0.6 }, // [!code highlight] fabLayout: { x: 0, y: 0, text: 'R1' }, // [!code highlight] }); r1.pcb = { x: 10, y: 10, rotation: 0 }; // Layouts can also be set after creation: // r1.referenceLayout = { x: 2, y: -1, rotation: 0 }; pcb.create(); ``` | Field | Type | Required | Description | |-------|------|----------|-------------| | `x` | `number` | Yes | X position in mm | | `y` | `number` | Yes | Y position in mm | | `rotation` | `number` | No | Rotation in degrees | | `layer` | `string` | No | KiCad layer name | | `width` | `number` | No | Font width in mm | | `height` | `number` | No | Font height in mm | | `fontSize` | `number` | No | Font size | | `font` | `string` | No | TrueType font face (KiCad `(face ...)`); omit for KiCad's default stroke font | | `thickness` | `number` | No | Text stroke thickness | | `bold` | `boolean` | No | Bold font style | | `italic` | `boolean` | No | Italic font style | | `justify` | `object` | No | `{ horizontal?: 'left'\|'right'\|'center', vertical?: 'top'\|'bottom'\|'middle', mirror?: boolean }` | | `show` | `boolean` | No | Visibility toggle | `fabLayout` additionally accepts an optional `text` field (`string`) that defaults to `${REFERENCE}` when omitted. To change the silkscreen font, set a TrueType face — the font must be installed on the machine that opens the board (KiCad falls back to its stroke font otherwise): ```ts r1.referenceLayout = { x: 0, y: -1.5, font: 'Arial', bold: true, height: 1.2 }; ``` `pcb.text()` accepts the same `font` field. ## Group or Place Components In KiCAD, you can group components together. They will move around together when you click and drag anywhere in the group. There is also a labeled box around the components. To accomplish this for a group of related components: ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); let pcb = new PCB('typecad_docs'); r1.pcb = { x: 10, y: 10, rotation: 0 }; pcb.group('typecad_docs', r1); // [!code highlight] pcb.create(); ``` Or to place them: ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); let pcb = new PCB('typecad_docs'); r1.pcb = { x: 10, y: 10, rotation: 0 }; pcb.group('typecad_docs', r1); // [!code --] pcb.place(r1); // [!code ++] pcb.create(); ``` ## Vias Vias can be created, placed and connected like any other component. Vias are connected through `pin(1)`. ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let typecad = new PCB('typecad_docs'); let r1 = new Resistor({ value: '1kohm' }); let via = typecad.via({ at: { x: 10, y: 10 }, size: 0.6, drill: 0.3, }); typecad.net(r1.pin(1), via.pin(1)); typecad.group('typecad_docs', r1, via); typecad.create(r1, via); ``` ### Power aware Vias can be created with the optional `powerInfo` object. This allows **type**CAD to check that the current draw through the via is within the limits of the via's rating using the IPC-2221 standard. `maxTempRise` is the maximum wanted rise in temperature of the via, default is 10 C. `thickness` is the thickness of the via's copper in microns. 35 is the default (1 oz). ## Outlines Board outlines can be created. ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); pcb.outline(100, 100, 50, 50, 1); // x, y, w, h, fillet pcb.create(); ``` Parameters are: - **x** — x position of the top-left corner - **y** — y position of the top-left corner - **width** — board width in mm - **height** — board height in mm - **fillet** — (optional) corner fillet radius in mm ### Arbitrary Outlines Beyond rectangles, typeCAD supports custom board shapes — polygons, circles, and internal cutouts (mounting holes, milled slots). All are emitted on the `Edge.Cuts` layer as native KiCad `gr_*` primitives. ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('board'); // custom polygon outline pcb.outlinePolygon([ { x: 0, y: 0 }, { x: 100, y: 0 }, { x: 100, y: 80 }, { x: 50, y: 100 }, { x: 0, y: 80 }, ]); // circular board pcb.outlineCircle(50, 50, 50); // center x, y, radius // internal cutout (e.g. a milled rectangular pocket) pcb.cutout([ { x: 20, y: 20 }, { x: 40, y: 20 }, { x: 40, y: 40 }, { x: 20, y: 40 }, ]); // circular cutout (mounting hole) pcb.cutoutCircle(25, 25, 3); // center x, y, radius ``` For outlines made of mixed line and arc segments (e.g. a DXF-imported shape), use the `outlinePath()` builder: ```ts pcb.outlinePath(0, 0) // start point .lineTo(100, 0) .arcTo(100, 80, { x: 150, y: 40 }) // end, then a point on the arc .lineTo(0, 80) .close(); // auto-closes back to the start ``` The `board()` bounds and edge-relative placement helpers (`fromLeft`, `fromRight`, etc.) work off the outline's bounding box, so they remain correct for any shape. KiCad treats nested closed contours on Edge.Cuts as cutouts — there is no separate cutout layer. ## Design Rules typeCAD writes board-wide design rules (minimum clearances, track/via dimensions) into the `.kicad_pro` project file so that `typecad drc` validates against them. The autorouter also honors these rules as its fallback clearance and track width. You don't need to open KiCad's Board Setup dialog to configure them. If you do nothing, rules default to the **JLCPCB no-surcharge standard** — the most permissive values JLCPCB manufactures without a premium surcharge: | Rule | Default | |---|---| | Min clearance | 0.20 mm | | Min track width | 0.20 mm | | Min via diameter | 0.60 mm | | Min through-hole (drill) diameter | 0.30 mm | | Min via annular width | 0.15 mm | | Min copper-to-edge clearance | 0.20 mm | | Min hole-to-hole | 0.25 mm | Pass a `rules` option to the `PCB` constructor to override any subset; the rest keep the JLC standard default: ```ts import { PCB } from '@typecad/typecad'; // dense board: tighten clearance and track width let pcb = new PCB('dense-board', { rules: { min_clearance: 0.15, min_track_width: 0.15 }, }); pcb.create(); ``` `pcb.rules` returns the fully resolved (merged) rules — useful when you want to read back the effective value after partial overrides: ```ts let pcb = new PCB('board', { rules: { min_clearance: 0.15 } }); console.log(pcb.rules.min_clearance); // 0.15 (overridden) console.log(pcb.rules.min_track_width); // 0.2 (JLC standard default) ``` The `Default` net class in the project file is kept consistent with these values, so the autorouter and DRC share a single source of truth. Per-route `width` and `clearance` passed to `pcb.route()` still take precedence over the board rules for that individual trace. > [!note] Checking rules > Run `typecad drc` to validate the board against these rules. See > [Tooling](/docs/tooling#typecad-drc) and the [CLI reference](/docs/cli). ## Net Classes Design rules apply board-wide. Net classes let you give a *specific group of nets* their own track width, clearance, and via dimensions — for example, wider traces and larger vias for power nets. Classes are written to the `.kicad_pro` project file (KiCad's `net_settings.classes`), enforced by DRC, and honored by the autorouter. Define a class with `pcb.netClass(name, options)`: | Option | Description | |---|---| | `track_width` | Trace width for nets in this class (mm). Defaults to rules min. | | `clearance` | Copper clearance for nets in this class (mm). Defaults to rules min. | | `via_diameter` | Via pad diameter for nets in this class (mm). Defaults to rules min. | | `via_drill` | Via drill for nets in this class (mm). Defaults to rules min. | | `layers` | Preferred routing layers for nets in this class (e.g. `['In1.Cu']`). Must be declared copper layers. | Then assign a net to it with `pcb.assign(netDef, className)`. `assign` takes the object returned by `pcb.net()` or `pcb.named().net()`, so it works for both named and auto-named nets: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('board'); // wider traces and bigger vias for power pcb.netClass('power', { track_width: 0.5, clearance: 0.3, via_diameter: 0.8, via_drill: 0.4, }); // named net const gnd = pcb.named('gnd').net(regulator.GND, mcu.GND); pcb.assign(gnd, 'power'); // also works for auto-named nets (the common case) const sw = pcb.net(regulator.LX, inductor.pin(1)); pcb.assign(sw, 'power'); ``` On an N-layer board, a class can also claim preferred routing layers — the autorouter anchors the net's through-hole endpoints on the class's layer and favors it while routing (a typeCAD routing directive; not written to the `.kicad_pro`): ```ts let pcb = new PCB('board', { layers: 4 }); // keep the SPI bus on the first inner layer pcb.netClass('spi', { layers: ['In1.Cu'] }); pcb.assign(spiNet, 'spi'); ``` Nets you don't assign fall back to the `Default` class, which mirrors the board [design rules](#design-rules). The autorouter resolves a net's class automatically and uses its dimensions — a per-route `width` or `clearance` passed to `pcb.route()` still takes precedence for that individual trace. ## Stackup The layer stackup describes the board's physical construction — copper, dielectric, solder mask, and silkscreen layers with their materials and thicknesses. KiCad stores it in the `(setup (stackup ...))` block of the `.kicad_pcb` and requires it for 4+ layer boards and impedance-controlled routing. The simplest way to build an N-layer board is the `layers` constructor option. It is the single source of truth for the board's copper layer set: routing defaults, through-hole pad clearance, and layer validation all derive from it. ```ts import { PCB } from '@typecad/typecad'; // 4-layer board — routing may use all four copper layers let pcb = new PCB('board', { layers: 4 }); // Inspect the resolved copper layers, top to bottom pcb.copperLayers; // ['F.Cu', 'In1.Cu', 'In2.Cu', 'B.Cu'] ``` For control over the stackup's materials, use `pcb.stackup()`. typeCAD generates a JLCPCB-standard stackup (FR4, 1oz copper, green mask). The total thickness comes from `pcb.thickness` (default 1.6mm) and the copper thickness from `pcb.copper_thickness` (default 35μm): ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('board'); // JLCPCB-standard 4-layer stackup at 1.6mm pcb.stackup(4); // 2-layer with a custom copper finish pcb.stackup(2, { copper_finish: 'ENIG' }); // 6-layer, thicker board — thickness flows from the constructor let pcb = new PCB('board', { thickness: 2.0 }); pcb.stackup(6); ``` The layer count can be any value from 2 to 32 (KiCad's maximum). Optional overrides: | Option | Description | |---|---| | `copper_finish` | Copper surface finish, e.g. `"None"`, `"HASL"`, `"ENIG"`. Default `"None"`. | | `dielectric_constraints` | Whether dielectric constraints are enforced. Default `false`. | | `layers` | Per-layer material overrides, keyed by layer name — see below. | ### Per-layer material overrides Individual layers can override the JLCPCB preset's thickness, material, dielectric constant, and loss tangent — keyed by copper layer name (`"In1.Cu"`), dielectric name (`"dielectric 2"`), or mask/silk name. Any remaining dielectric budget is redistributed across the non-overridden dielectrics so the board still totals `pcb.thickness`: ```ts let pcb = new PCB('board', { layers: 4 }); pcb.stackup(4, { layers: { 'dielectric 1': { thickness: 0.21, epsilon_r: 4.4 }, 'dielectric 2': { material: 'Rogers 4350B', epsilon_r: 3.48, loss_tangent: 0.0037 }, }, }); ``` ### Controlled impedance `pcb.impedanceWidth(layer, targetOhms)` computes the trace width that hits a target characteristic impedance on a copper layer of the board's stackup — outer layers are modeled as microstrip, inner layers as symmetric stripline. `pcb.route()` uses it automatically when you pass an `impedance` constraint (the trace is only ever widened, never below the design-rule floor): ```ts // what width hits 50Ω on the first inner layer? pcb.impedanceWidth('In1.Cu', 50); // e.g. 0.354 (mm) // with a ±5Ω tolerance the width snaps to a 0.01mm // fabrication grid inside the 50±5Ω band: pcb.impedanceWidth('F.Cu', 50, 5); // autoroute a net at 100Ω (tolerance optional); if the design-rule // floor forces the trace outside the band, routing warns with the // achieved impedance pcb.route(clk, { impedance: { target: 100, tolerance: 10 } }); ``` Accuracy is engineering-grade (typically within fab tolerance), not field-solver grade. An unreachable target (e.g. 1Ω) throws a `RangeError`. When you configure the layer count (either way), typeCAD regenerates the board's `(layers ...)` declaration block to match (so the layer declarations and the stackup stay consistent) and writes the board thickness into `(general (thickness ...))`. Every layer referenced by a zone, keepout, via, or route is validated against the declared layer set when the board is written — referencing `"In3.Cu"` on a 4-layer board fails with an actionable error instead of producing a broken `.kicad_pcb`. ### Planes `pcb.plane(net, layer)` dedicates a copper layer to a net. At `create()` the plane becomes a board-covering filled zone on that layer (through-hole pads connect solidly; SMD pads reach it through vias), and the layer is removed from the autorouter's default routing layers: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('board', { layers: 4 }); pcb.outline(0, 0, 50, 40); pcb.plane('GND', 'In1.Cu'); pcb.plane('+3V3', 'In2.Cu'); ``` The plane extent comes from the board outline, so call `pcb.outline()` before `create()`. A layer can carry only one plane; signal routes stay off plane layers unless a `pcb.route()` call explicitly asks for them. ### Via policy Vias placed by the autorouter follow a manufacturing policy set with `pcb.viaPolicy()`: ```ts // default: every router via spans F.Cu→B.Cu (through via) — // always manufacturable at budget fabs pcb.viaPolicy({ type: 'through' }); // opt in to blind/buried vias: the router uses the exact layer // pair a route transitions between, up to `maxSpan` layer // boundaries (default 2); deeper transitions fall back to through vias. // Via cost scales with span depth, so the router prefers shallow vias. pcb.viaPolicy({ type: 'blind-buried', maxSpan: 2 }); ``` ## Tracks Traces can be created manually using `pcb.track()` for point-to-point routing with vias: ```ts import { PCB } from '@typecad/typecad'; 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); ``` Tracks are created by going from point to point, using vias to transition between layers. Nets and connections are not required to be specified. KiCAD will connect any track that touches an element with a net. ### Auto-routing For automatic pin-to-pin routing, use `pcb.route()`: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); let tracks = await pcb.route({ from: r1.pin(1), to: r2.pin(2), }); pcb.create(r1, r2, ...tracks); ``` `route()` finds an optimized path between the `from` and `to` pins. Options include: - _from_ / _to_ — pin or array of pins (required) - _width_ — trace width in mm (calculated from `powerInfo` if omitted) - _layers_ — restrict to specific copper layers (e.g. `['F.Cu', 'B.Cu']`) - _powerInfo_ — `{ current, maxTempRise, thickness }` for automatic IPC-2221 trace width calculation - _waypoints_ — array of `{ x, y }` points to guide the path - _clearance_ — minimum clearance from other objects in mm ## Zones Filled copper zones (e.g., ground pours) and keepout areas can be added to the board: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('zone_example'); pcb.zone({ net: 'GND', layers: ['B.Cu'], x: 0, y: 0, width: 50, height: 30, }); pcb.keepout({ layers: ['F.Cu', 'B.Cu'], x: 20, y: 10, width: 20, height: 15, restrictions: { tracks: true, vias: true, copperpour: true }, }); pcb.create(); ``` ### Zone options Beyond the rectangle (`x`/`y`/`width`/`height`), a zone accepts an explicit polygon via `points` (≥ 3 vertices), or a bounds rectangle via `bounds` (≥ e.g. `bounds: pcb.board` — provide one form, not combinations). `net` (or `pin`) attaches the pour to a net; omitting both creates an unconnected pour (KiCad net 0): ```ts // full-board pour, no field mapping pcb.zone({ net: 'GND', bounds: pcb.board, layers: ['F.Cu', 'B.Cu'] }); ``` ```ts // L-shaped ground pour pcb.zone({ net: 'GND', layers: ['F.Cu'], points: [ { x: 10, y: 10 }, { x: 20, y: 10 }, { x: 20, y: 14 }, { x: 14, y: 14 }, { x: 14, y: 20 }, { x: 10, y: 20 }, ], }); ``` Commonly used options: | Option | Description | |---|---| | `points` | Arbitrary polygon geometry (≥ 3 vertices); alternative to the rectangle. | | `bounds` | Bounds rectangle — `bounds: pcb.board` passes the outline straight through. | | `fill` | Grouped fill settings (see below); `false` creates an unfilled outline. | | `priority` | Zone priority — higher-priority zones win overlaps. Default 0. | | `clearance` | Clearance from pads. Default 0.2mm. | | `connectPads` | `'thru_hole_only'`, `'full'`, or `'no'` pad connections. Default: thermal relief. | | `minThickness` | Minimum fill thickness. Default 0.1778mm. | | `filledAreasThickness` | Whether filled areas use the minimum thickness. | | `name` / `locked` | Zone name and lock flag. | Fill settings can be passed grouped in a single optional `fill` object — mirroring KiCad's `(fill ...)` block — instead of one flat option at a time: ```ts pcb.zone({ net: 'GND', layers: ['F.Cu'], x: 0, y: 0, width: 50, height: 30, fill: { mode: 'hatched', // 'solid' (default) or 'hatched' thermalGap: 0.3, thermalBridgeWidth: 0.5, smoothing: 'fillet', smoothingRadius: 0.5, islandRemovalMode: 2, // 0 = keep, 1 = always remove, 2 = below islandAreaMin islandAreaMin: 4, hatchThickness: 0.2, // hatched fill only (alias: hatchWidth —) hatchGap: 0.8, // KiCad's dialog calls hatchThickness "Hatch width" hatchOrientation: 45, hatchSmoothingLevel: 1, hatchSmoothingValue: 0.1, hatchBorderAlgorithm: 'min_thickness', hatchMinHoleArea: 0.5, arcSegments: 24, }, }); // outline-only zone (no fill): pcb.zone({ net: 'GND', layers: ['B.Cu'], x: 0, y: 40, width: 20, height: 10, fill: false }); ``` The same settings are also accepted as flat zone options (`fillMode`, `thermalGap`, `islandRemovalMode`, `hatchThickness`, ...); when both are given, the `fill` object wins per field. `hatchWidth` is accepted everywhere `hatchThickness` is — KiCad's zone dialog labels the setting "Hatch width" while the file token is `hatch_thickness`; the file-token name wins when both are given at the same level. ### Keepout options Keepouts take the same geometry (`bounds`, rectangle, or `points`) plus per-category `restrictions` (`tracks`, `vias`, `pads`, `copperpour`, `footprints` — all default to restricted) and the rule-area `placement` option (also applies to footprints placed from a schematic sheet; default false). See also [planes](#planes) for dedicating a whole copper layer to a net. ## Graphics Draw graphical elements on the PCB: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('graphics_example'); pcb.line({ start: { x: 0, y: 0 }, end: { x: 10, y: 10 }, layer: 'F.SilkS', width: 0.15 }); pcb.circle({ center: { x: 25, y: 25 }, radius: 5, layer: 'F.SilkS', width: 0.15 }); pcb.rect({ x: 0, y: 0, width: 20, height: 15, layer: 'Edge.Cuts', strokeWidth: 0.15 }); pcb.arc({ start: { x: 10, y: 10 }, mid: { x: 13.5, y: 13.5 }, end: { x: 15, y: 10 }, layer: 'F.SilkS', width: 0.15 }); pcb.text({ text: 'REV 1.0', x: 5, y: 5, layer: 'F.SilkS', width: 1, height: 1 }); pcb.create(); ``` Arcs use KiCad's three-point definition: `start`, `mid` (a point on the arc), and `end`. ## Via Stitching `pcb.stitch(net, options?)` ties a net across layers with a grid of vias — the standard way to connect outer-layer pours to inner [planes](#planes). Like `pcb.plane()`, stitching is a declaration: the vias are placed at `create()` time against the complete board contents — every component passed to `create()` is considered, net or no net, so nothing needs to be registered beforehand. Candidates on a pitch grid are skipped when they would violate clearance against existing copper (pads, tracks, vias, zones, keepouts) on any layer the stitch spans; same-net pours never block. Component footprints block stitches regardless of net (full keep-clear extent — a mounting hole's screw-head zone, not just its pad), and board text blocks stitches on its side of the board so silkscreen stays readable. A `pitch` smaller than the via size plus clearance is rejected at the call. ```ts pcb.plane('GND', 'In2.Cu'); pcb.zone({ net: 'GND', layers: ['F.Cu'], x: 0, y: 0, width: 50, height: 30 }); pcb.stitch('GND', { pitch: 1.5 }); // vias placed at create() ``` | Option | Description | |---|---| | `layers` | The layers the vias span (default: all copper layers, i.e. through vias). A partial span like `['F.Cu', 'In1.Cu']` emits blind vias over exactly that range. | | `pitch` | Grid spacing in mm. Default 1.5. Must be at least `size` + clearance. | | `size` / `drill` | Via dimensions. Default: design-rule minimums. | | `area` | Restrict stitching to a region (default: the board outline); accepts bounds-style rectangles. | | `margin` | Inset from the board edge in mm. Default 0.5. | ## Teardrops `pcb.teardrops(options?)` reinforces track-to-via junctions. It writes KiCad's teardrop tool settings to the `.kicad_pro` (so boards open preconfigured) and, for vias placed by the autorouter, generates the teardrop geometry itself — tapered side segments on each layer the via connects: ```ts pcb.teardrops(); // defaults: vias + pads, round, ≤1mm pcb.teardrops({ maxLength: 0.8, shape: 'rect' }); // straight-sided wedges ``` | Option | Description | |---|---| | `vias` / `throughHolePads` / `smdPads` / `trackEnds` | Which junctions get teardrops. Defaults: all but `trackEnds`. | | `shape` | `'round'` (curved sides, default) or `'rect'` (straight-sided). | | `maxLength` / `maxHeight` | Wedge caps in mm. Defaults 1.0 / 2.0. | ## Round-Trip Editing with `typecad import` You can lay out components, draw tracks, and place vias in the KiCAD interactive editor, then sync those changes back into your **type**CAD source code using `typecad import`. ### Snippet Mode Print generated **type**CAD code snippets for the board layout: ```bash typecad import ./build/board.kicad_pcb ``` This outputs component positions, `TrackBuilder` chains, vias, and outlines as TypeScript snippets you can copy into your code. ### Apply Mode (Round-Trip Sync) Interactively apply layout changes from a `.kicad_pcb` file back to your source `.ts` files: ```bash typecad import ./build/board.kicad_pcb --apply ``` This compares the KiCAD board file against your **type**CAD source, shows coordinate and side changes for each component, and lets you select which ones to write back. This is particularly useful for [packages](/docs/package/overview): lay out the entire package in KiCAD, then round-trip the positions back into your package code. --- ## Classes *Classes* ## `PCB` The main class that represents the entire circuit. ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad_concepts', {thickness: 1.6, copper_thickness: 35 }); ``` The only required option is the name. The name determines the name of the resulting KiCAD files (.kicad_pcb, .kicad_sch, and .net). Optional properties are: `{thickness: 1.6, copper_thickness: 35 }` - thickness — board thickness in mm - copper_thickness — copper thickness in microns (1 oz = 35 microns) These are used in power-aware calculations. The `PCB` class is where: - Components are added - Connections are made between components - Board layout is defined - Board outlines are drawn — rectangles, polygons, circles, cutouts, and free-form line/arc paths - Utility functions like ERC and BOM - Routing with `route()` and `autorouteBatch()` - Zones, keepout areas, and graphics ## `Component` The `Component` class represents individual parts like resistors, capacitors, ICs, etc. You add a `Component` to your `PCB`. ```ts import { Component } from '@typecad/typecad'; let R1 = new Component({ value: '1kohm' }); ``` Options for the `Component` class are: - _reference_ — reference designator - _value_ — value of component - _footprint_ — footprint - _symbol_ — KiCAD symbol library path - _prefix_ — prefix for reference designator - _datasheet_ — link to component datasheet - _description_ — description of component - _voltage_ — voltage rating of component - _wattage_ — wattage rating of component - _mpn_ — Manufacturer Part Number - _dnp_ — true if component is Do Not Populate, false to place component - _simulation_ — an object with simulation data `{ include: true, model: 'ngspice-model' }` - _pcb_ — position on the board `{ x, y, rotation }` - _text_ — array of arbitrary text entries on the board, each with `property`, `text`, position, and styling - _fab_ — fabrication layer text entry; accepts a positioning object or `[text, positioning]` tuple - _referenceLayout_ — controls reference designator text position and style (defaults to **F.SilkS** layer) - _valueLayout_ — controls value text position and style (defaults to **F.Fab** layer) - _fabLayout_ — controls fabrication text position and style (defaults to **F.Fab** layer); `text` defaults to `${REFERENCE}` if omitted All three layout properties accept an `ITextPositioning` object and can be set at construction or assigned after creation: ```ts import { Component } from '@typecad/typecad'; let r1 = new Component({ footprint: 'Resistor_SMD:R_0603_1608Metric', reference: 'R1', referenceLayout: { x: 0, y: -1.5, rotation: 90, width: 0.8, height: 0.8 }, valueLayout: { x: 0, y: 1.5, width: 0.6, height: 0.6 }, fabLayout: { x: 0, y: 0, text: 'R1' }, }); // Or assign after creation: r1.referenceLayout = { x: 2, y: -1, rotation: 0 }; ``` ### `ITextPositioning` Fields | Field | Type | Required | Description | |-------|------|----------|-------------| | `x` | `number` | Yes | X position in mm | | `y` | `number` | Yes | Y position in mm | | `rotation` | `number` | No | Rotation in degrees | | `layer` | `string` | No | KiCad layer name | | `width` | `number` | No | Font width in mm | | `height` | `number` | No | Font height in mm | | `fontSize` | `number` | No | Font size | | `thickness` | `number` | No | Text stroke thickness | | `bold` | `boolean` | No | Bold font style | | `italic` | `boolean` | No | Italic font style | | `justify` | `object` | No | `{ horizontal?: 'left'\|'right'\|'center', vertical?: 'top'\|'bottom'\|'middle', mirror?: boolean }` | | `show` | `boolean` | No | Visibility toggle | `fabLayout` extends `ITextPositioning` with an optional `text` field (`string`) that defaults to `${REFERENCE}`. > [!note] Syntax > **type**CAD makes use of the above syntax style for many of its classes, ie. passing an object of optional properties. *Optional* in terms of TypeScript code, if a particular property isn't passed and **type**CAD requires it, it will throw an error during build. ## `Power` Represents a power source like a battery or voltage regulator. ```ts import { Power } from '@typecad/typecad'; let coin_cell = new Power({ power: holder.pin(1), gnd: holder.pin(2), voltage: 3.7 }); ``` Options are: - _power_ — pin on a component that supplies power - _gnd_ — pin on a component that supplies ground - _voltage_ — voltage of power source - _current_ — current capacity of the power source - _direction_ — `output` for power sources, `input` for power consumers ## `Package` Abstract base class for creating reusable, importable hardware modules. Extend this class to encapsulate a circuit sub-design (e.g. a voltage regulator, sensor module, or MCU subsystem). ```ts import { Package, Component } from '@typecad/typecad'; export class MyResistor extends Package { declare resistor: Component; build(options) { this.resistor = new this.passives.Resistor({ value: '10kohm' }); this.resistor.pcb = { x: 100, y: 100, rotation: 0 }; } } ``` The constructor handles offset positioning (`x`, `y`), auto-collects all `Component` properties set on `this`, groups them on the PCB, and automatically syncs the package's bundled KiCad symbol/footprint files (its `./build/lib/`) into the project's `./build/lib/` directory — no install script required. For classes that don't extend `Package`, the exported `syncThisPackageBuildLib()` helper provides the same sync with one call. ## `TrackBuilder` Fluent API for creating tracks on the PCB: ```ts import { PCB, TrackBuilder } from '@typecad/typecad'; let pcb = new PCB('tracks'); let track: TrackBuilder = 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(); ``` --- ## Cli *CLI Reference* All **type**CAD commands are accessed through the `typecad` binary, included with `@typecad/typecad`. ## Global Options | Option | Description | |--------|-------------| | `--json` | Output results as JSON | | `--help` | Show help for any command | | `--version` | Show the typeCAD version | ## Commands ### `typecad create` Create a new typeCAD project. ```bash typecad create [options] ``` | Option | Description | |--------|-------------| | `--name ` | Project name | | `--pio ` | Create a PlatformIO project | | `--board ` | PlatformIO board ID | | `--git ` | Initialize a git repository | | `--packages ` | Comma-separated list of packages to install | ### `typecad build` Build the typeCAD project and generate KiCAD output files. ```bash typecad build [options] ``` | Option | Description | |--------|-------------| | `--verbose` | Show detailed build output | ### `typecad add component` Add a component to the project. ```bash typecad add component [options] ``` | Option | Description | |--------|-------------| | `--symbol_source ` | Source for the symbol file | | `--footprint_source ` | Source for the footprint file | | `--symbol ` | Symbol library path and name | | `--footprint ` | Footprint library path and name | | `--c ` | JLCPCB component number | | `--symbol_file ` | Path to local symbol file | | `--footprint_file ` | Path to local footprint file | ### `typecad add package` Create a reusable typeCAD package. ```bash typecad add package [options] ``` | Option | Description | |--------|-------------| | `--empty ` | Create an empty package | | `--component ` | Create a component-based package | | `--name ` | Package name | | `--kicad ` | Use KiCAD as source | | `--local ` | Use local files as source | | `--jlcpcb ` | Use JLCPCB as source | | `--symbol ` | Symbol for component package | | `--footprint ` | Footprint for component package | | `--c ` | JLCPCB component number | ### `typecad search` Search KiCAD symbol libraries with fuzzy matching. ```bash typecad search [options] ``` | Option | Description | |--------|-------------| | `--format ` | Output format (default: text) | | `--sort ` | Sort results by field | | `--limit ` | Maximum number of results | ### `typecad import` Convert a KiCAD PCB file to typeCAD code. ```bash typecad import [options] ``` | Option | Description | |--------|-------------| | `--apply` | Interactively apply coordinates to source files | ### `typecad diff` Compare two KiCAD PCB files visually. ```bash typecad diff [options] ``` | Option | Description | |--------|-------------| | `--full` | Compare all layers | | `--theme ` | Color theme for the report | | `--output ` | Output HTML file path | ### `typecad doc` Generate HTML documentation from Markdown + KiCAD PCB. ```bash typecad doc [options] ``` | Option | Description | |--------|-------------| | `-o ` | Output HTML file path | | `-v` | Verbose output | | `-q` | Quiet mode | | `--no-open` | Don't open the file after generation | ### `typecad doctor` Check your environment for required tools. ```bash typecad doctor [options] ``` | Option | Description | |--------|-------------| | `--fix` | Attempt automatic fixes | | `--json` | Machine-readable output | ### `typecad validate` Validate source without full build. ```bash typecad validate [options] ``` | Option | Description | |--------|-------------| | `--verbose` | Show detailed output | | `--json` | Machine-readable output | ### `typecad drc` Run KiCAD Design Rule Check. The rules DRC validates against are configurable in code — see [Board Layout → Design Rules](/docs/board_layout#design-rules). ```bash typecad drc [options] ``` | Option | Description | |--------|-------------| | `--json` | Machine-readable output | ### `typecad erc` Run KiCAD Electrical Rules Check. ```bash typecad erc [options] ``` | Option | Description | |--------|-------------| | `--json` | Machine-readable output | ### `typecad skills` List and query typeCAD skills and API patterns. ```bash typecad skills list [options] typecad skills get [options] ``` | Subcommand | Description | |------------|-------------| | `list` | List all available skills, grouped by category | | `get ` | Show details for a specific skill (usage, parameters, examples) | | Option | Description | |--------|-------------| | `--json` | Machine-readable output | ```bash typecad skills list typecad skills get resistor typecad skills get power --json ``` --- ## Components *Components* A component is anything that has a KiCAD symbol or footprint, ie. resistors, MCUs, vias, mounting holes or regulatory images. ## `Component` The `Component` class is the base class for all components in **type**CAD. In KiCAD, it would be anything that has a footprint file associated with it. ```ts import { Component } from '@typecad/typecad'; let u1 = new Component({ footprint: 'Package_SO:SOIC-8_5.3x5.3mm_P1.27mm' }); ``` The above creates a SOIC-8 component. `footprint` is the KiCAD footprint path and split into two strings. That method works well for simple components, but there is a better way using the `typecad add component` tool. ## `typecad add component` **type**CAD has a command line tool that can be used to create a component. Run `typecad add component` from the `./hw` directory, or click the `add_component` button in the VSCode GUI under `NPM Scripts`. The script will ask where the component is coming from, either the KiCAD library, a local file, or an EasyEDA/JLCPCB component. If you're using the KiCAD library, you'll be asked for the symbol library and name. Paste it in, press enter and it should automatically figure out which footprint to use. If it can't, it will ask you for a footprint library name and footprint name (library.kicad_mod:footprint). If you're using a local file, you'll be asked for the path to the symbol file and footprint file. If it's an [EasyEDA/JLCPCB component](https://jlcpcb.com/parts), you'll be asked for the `C###` number. ### KiCAD Library Components To find the symbol and footprint for a KiCAD library component, use `typecad search`: ```bash typecad search "voltage regulator" typecad search LM358 typecad search "op amp" --format=json --limit=10 ``` It fuzzy-matches against the KiCAD symbol libraries and returns the symbol name, footprint, and description. The symbol name is in `LibraryName:SymbolName` format (e.g. `MCU_Microchip_ATtiny:ATtiny85-20S`). Without a query, it prompts for search terms interactively. Available options: - `--format` — output format: `detailed`, `compact`, `table`, `json` (default: detailed) - `--sort` — sort by: `score`, `id`, `manufacturer`, `package` (default: score) - `--limit` — maximum number of results (default: 5) ### EasyEDA/JLCPCB Component If you are working within JLC's ecosystem for design or assembly, you can use the `C###` numbers of their parts to create a component. The footprint and 3d model will be downloaded and a **type**CAD component will be created. > [!WARNING] > The parts are converted from EasyEDA's format to KiCAD's footprint. The conversion isn't always perfect. The most common issue is pin types being `unspecified` rather than what they should actually be. Not all parts have associated symbols or footprints. ### Component Use After the component is created, they'll be some code in the terminal that tells you how to `import` it and declare a `new` instance of it. For the ATtiny85, it will look like this: ```bash # [!code word:import] # [!code word:new] 🧩 typeCAD Create Component ✔ Component source? KiCAD ✔ Symbol name? MCU_Microchip_ATtiny:ATtiny3227-M ✔ Footprint name? Package_DFN_QFN:QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm Finished component creation, use it with: import { ATtiny85_20S } from './ATtiny85_20S'; let u1 = new ATtiny85_20S(); ``` Let's look at what's in the `ATtiny85_20S.ts` file that was created to get a better idea of what is going on. ### `ATtiny85_20S.ts` ```ts import { Component } from '@typecad/typecad'; /** | Pin # | Name | Type | | --: | :-- | :-- | | 8 | VCC | power_in | | 4 | GND | power_in | | 5 | AREF_PB0 | bidirectional | | 6 | PB1 | bidirectional | | 7 | PB2 | bidirectional | | 2 | XTAL1_PB3 | bidirectional | | 3 | XTAL2_PB4 | bidirectional | | 1 | _RESET_PB5 | bidirectional | */ export class ATtiny85_20S extends Component { VCC = this.pin(8, { type: 'power_in' }); GND = this.pin(4, { type: 'power_in' }); AREF_PB0 = this.pin(5, { type: 'bidirectional' }); PB1 = this.pin(6, { type: 'bidirectional' }); PB2 = this.pin(7, { type: 'bidirectional' }); XTAL1_PB3 = this.pin(2, { type: 'bidirectional' }); XTAL2_PB4 = this.pin(3, { type: 'bidirectional' }); _RESET_PB5 = this.pin(1, { type: 'bidirectional' }); constructor(reference?: string | undefined) { super("Package_SO:SOIC-8_5.3x5.3mm_P1.27mm"); this.symbol = "MCU_Microchip_ATtiny:ATtiny85-20S"; if (reference) this.reference = reference; } } ``` It is a bit more involved than the simple TypeScript we've been using so far (that's why it was auto-generated). But it helps to explain what is going on. The file `extends` the `Component` by adding some extras to it. In particular, it adds `Pin` objects to the component. Rather than using the pins like `u1.pin(1)`, we can use `u1.VCC` for the VCC pin, or `u1.GND` for the GND pin. This makes the code much easier to read and understand. `minimum_voltage`, `maximum_voltage`, and `current` are optional and provide additional information for the power-aware system to check trace widths, and ensure voltage/current restrictions are met. ## `create` After a `Component` has been created and modified, call `create` to include it in the PCB, schematic and netlist. ```ts import { PCB } from '@typecad/typecad'; import { ATtiny85_20S } from './ATtiny85_20S'; let typecad = new PCB('typecad_docs'); let u1 = new ATtiny85_20S(); typecad.create(u1); ``` --- ## Concepts *Concepts* Instead of using the KiCAD schematic editor, you write code and then build it into a KiCAD project. **type**CAD uses TypeScript. You don't need an extensive knowledge of TypeScript to get started. If you're familiar with any programming language, you can pick up the basics of TypeScript pretty quickly. > [!faq]- Why TypeScript? > One of the long-term goals of **type**CAD was to integrate hardware design into the realm of AI. Most AI-based tools understand TypeScript very well and don't need special training to use it effectively. > TypeScript is also relatively simple to learn and use. ## KiCAD The normal flow in KiCAD is: 1. Create a project with a schematic and board 2. Add components 3. Make connections 4. Layout the board ## **type**CAD **type**CAD replaces steps 1-3. Instead of clicking and dragging to place components and make connections, TypeScript code is used. This is how a PCB is created. ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad'); typecad.create(); ``` That code will create a KiCAD board file, schematic file, netlist and BOM in `./build/typecad.kicad_pcb`, `./build/typecad.kicad_sch`, `./build/typecad.net`, and `./build/typecad.csv`. ### Build Run `typecad build` from your project's `hw/` directory to build. You can configure the build using a `typecad.conf.ts` file in the `hw/` directory. ### Workflow The new layout becomes: 1. Create a **type**CAD project 2. Edit the code to add components and make connections 3. Build it 4. Open the board in KiCAD to layout Design rules (minimum clearances, track/via dimensions) default to the JLCPCB no-surcharge standard and are written to the project file for DRC; see [Board Layout → Design Rules](/docs/board_layout#design-rules). You only need to open KiCad for the final visual layout pass. --- ## Configuration *Configuration* Everything should work out-of-the-box, but there are several items that can be customized. **type**CAD projects can be configured using a `typecad.conf.ts` file in the project's `hw/` directory. This file lets you specify build settings, KiCAD paths, and other options. ## `typecad.conf.ts` ```ts import { defineConfig } from '@typecad/typecad'; export default defineConfig({ entry: 'src/index.ts', kicad_cli: '/usr/bin/kicad-cli', kicad_path: '/usr/share/kicad', use_flatpak: false, verbose: false, }); ``` ### Options | Option | Type | Description | |--------|------|-------------| | `entry` | `string` | Path to the TypeScript entry file (relative to `hw/`) | | `kicad_cli` | `string` | Path to the `kicad-cli` binary | | `kicad_path` | `string` | Path to the KiCAD installation directory | | `use_flatpak` | `boolean` | Prioritizes a Flatpak installation if ``true`` | | `verbose` | `boolean` | Enable verbose output during builds | ## KiCAD Detection **type**CAD automatically detects KiCAD installations on your system. It supports: - **Windows**: Standard install locations - **macOS**: `/Applications/KiCad/` - **Linux**: `/usr/share/kicad`, `/usr/local/share/kicad` - **Flatpak**: Auto-detected when `use_flatpak` Supported versions: KiCAD 10.0. ## `typecad doctor` Use `typecad doctor` to verify your configuration and environment: ```bash typecad doctor ``` This checks that KiCAD, Node.js, and all required tools are installed and accessible. Use `--fix` to attempt automatic fixes and `--json` for machine-readable output. --- ## Connections *Connections* In **type**CAD, connections are created by calling the `PCB::net()` function. Connections are made between components in the same `PCB`. The `net()` function takes a list of `Pin` objects. ## Connecting Pins ```ts import { Capacitor } from '@typecad/passives/0805' import { ATtiny85_20S } from './ATtiny85_20S'; import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad_docs'); let u1 = new ATtiny85_20S(); let c1 = new Capacitor({ value: '1uF' }); typecad.net(u1.VCC, c1.pin(1)); // power [!code highlight] typecad.net(u1.GND, c1.pin(2)); // ground [!code highlight] ``` We've connected pin 1 of the capacitor to the VCC pin of the ATtiny85 and pin 2 to the GND pin. `::net()` takes any number of `Pin` objects, so you can connect multiple pins at once. ### Named Connections Sometimes it is useful to name the connection. The net name will be visible in KiCAD, it can be useful when laying out the board. Some **type**CAD utility functions will only pay attention to named connections as well. If you don't name the connection, it will be `net#`. ```ts typecad.net(u1.VCC, c1.pin(1)); // [!code --] typecad.named('power').net(u1.VCC, c1.pin(1)); // [!code ++] ``` The connection in KiCAD will now be labled `power`. ## Common Connection Patterns ### Power Distribution Connect multiple components to the same power rail: ```ts // Power distribution pattern typecad.named('VCC').net( microcontroller.VDD, cap1.pin(1), cap2.pin(1), connector.pin(1) ); ``` ### Ground Distribution Connect multiple ground pins together: ```ts // Ground distribution pattern typecad.named('GND').net( microcontroller.GND, microcontroller.GND_2, // if component has multiple ground pins cap1.pin(2), cap2.pin(2), connector.pin(2) ); ``` ### Signal Connections Connect signal pins between components: ```ts // Signal connections typecad.named('SDA').net(microcontroller.PB0, sensor.SDA); typecad.named('SCL').net(microcontroller.PB1, sensor.SCL); ``` > [!WARNING] > **type**CAD merges nets with similar `Pin` connections. If you make a connection to an already connected pin, that newer net will be merged into the existing net. This will mean your `named` net may not keep the name you give it if it is merged with another net later. You'll see a warning in the build output if this happens. --- ## Docgen *DocGen* The `typecad doc` command generates self-contained HTML documentation from a Markdown file and a KiCAD PCB file. It automatically exports PCB layers as inline SVGs and supports rich formatting. ## Usage ```bash typecad doc docs/board.md build/board.kicad_pcb -o output.html ``` ### Options | Option | Description | |--------|-------------| | `-o ` | Output HTML file path | | `-v` | Verbose output | | `-q` | Quiet mode (suppress output) | | `--no-open` | Don't open the file after generation | ## Markdown Features DocGen supports standard Markdown plus several extensions: ### Code Highlighting Syntax highlighting powered by Shiki. Add a filename with `lang:filename` syntax: ````markdown ```typescript:index.ts let r1 = new Resistor({ value: '1kohm' }); ``` ```` ### PCB Layer Exports Embed PCB layers directly in your Markdown using `{layers}` in image alt text: ```text ![{F.Cu,F.SilkS,F.Mask}](placement.svg =600) ``` This exports the `F.Cu`, `F.SilkS`, and `F.Mask` layers as an inline SVG, sized to 600px wide and merged together in the order they are listed. Use `=50%` for percentage-based sizing, or `=600x400` to set both width and height. ### 3D Renders Include 3D renders of the board: ```markdown ![{Render/top/0/0/0}](render.png) ![{Render/bottom/45/30/0}](render-bottom.png =400) ``` Parameters are: `{Render/side/rotation_x/rotation_y/rotation_z}`. `side` can be `top` or `bottom`. ### Drill Maps and Layer Stackups ```markdown ![{Drill}](drill.svg) ![{Stackup}](stackup.svg) ``` ### GitHub Alerts Styled callout blocks for notes, tips, warnings, important messages, and cautions: ```markdown > [!NOTE] > This is a note. > [!TIP] > This is a helpful tip. > [!IMPORTANT] > Critical information here. > [!WARNING] > Something to be careful about. > [!CAUTION] > Proceed at your own risk. ``` ### Math Both inline and block math using `$` for AsciiMath and `$$` for LaTeX: ```markdown The impedance is $Z = sqrt(R^2 + (w L - 1/(w C))^2)$. $$ P = V \times I = I^2 R = \frac{V^2}{R} $$ ``` ### UML Diagrams Embed PlantUML diagrams directly in your Markdown: ````markdown ```plantuml @startuml MCU --> Sensor : I2C MCU --> Radio : SPI @enduml ``` ```` ### Task Lists Checkbox-style lists that render as interactive toggles: ```markdown - [x] Schematic review complete - [x] ERC passed - [ ] Layout review - [ ] DRC clean ``` ### Multi-row Tables Extended table support with multiline cells, row spanning, and multiple bodies: ```markdown | Reference | Value | Footprint | Description | |-----------|--------|-----------|--------------------| | U1 | 328P | TQFP-32 | Main MCU \\ | | | | | ATmega series | | R1 | 10k | 0603 | Pull-up | | R2 | 4.7k || | Pull-down | |-----------|--------|-----------|--------------------| | C1 | 100nF | 0603 | Decoupling | | C2 | 10uF | 0805 | Bulk cap | ``` A trailing `\` continues a cell onto the next line. An empty `||` merges a cell with the one above it. A second separator row (`|---|`) splits the table into multiple bodies. ### Custom Attributes Add HTML-like attributes to elements using `{...}` syntax: ```markdown # Board Layout {.custom-heading} This paragraph has a CSS class. { .important } ![Photo](board.jpg){.bordered .shadow} ``` ## Frontmatter Configure the document using YAML frontmatter: ```yaml --- title: My Board Documentation company: Acme Corp board_name: SensorBoard variant: Rev A revision: "1.0" date: 2026-01-15 highlight_theme: github-dark stylesheet: custom.css kicad_theme: Monokai dark_mode: true --- ``` ## Programmatic API You can also use docgen programmatically: ```ts import { generateDocumentation } from '@typecad/typecad/docgen'; await generateDocumentation('input.md', 'board.kicad_pcb', 'output.html', { verbose: true, }); ``` --- ## Gitdiff *Git Diff* The `typecad diff` command provides visual comparison of KiCAD PCB files with layer-by-layer diff, netlist comparison, and BOM diff. It generates an interactive HTML report you can open in any browser. ## Usage ### File-to-file comparison ```bash typecad diff board_v1.kicad_pcb board_v2.kicad_pcb ``` ### Git revision comparison Compare a git revision against the current working copy: ```bash typecad diff HEAD~1 ./build/board.kicad_pcb ``` Compare two git revisions: ```bash typecad diff HEAD~1 HEAD -- board.kicad_pcb ``` ## Options | Option | Description | |--------|-------------| | `--full` | Include User layers (User.1–9, User.Drawings, User.Comments, User.Eco1/2) in the comparison | | `--theme ` | Color theme for the report (default: `Monokai`) | | `--output ` | Output HTML file path | ## View Modes The generated HTML report supports multiple view modes: - **Side-by-side**: View original and modified layers next to each other - **Overlay**: Superimpose both versions to see alignment - **Onion skin**: Semi-transparent overlay for precise comparison - **Diff only**: Show only the differences with color highlighting - **Swipe**: Drag a divider to reveal before/after ## Textual Diff In addition to the visual comparison, `typecad diff` provides: - **Netlist diff**: Shows added, removed, and modified nets with their connected pins - **BOM diff**: Compares component lists between revisions, highlighting added/removed/changed parts ## Programmatic API You can also use the diff functionality programmatically: ```ts import { generateDiffs } from '@typecad/typecad/diff'; await generateDiffs({ originalFile: 'old.kicad_pcb', modifiedFile: 'new.kicad_pcb', fullMode: false, theme: 'Monokai', outputHtmlPath: './report.html', }); ``` --- ## Hardware Contract *Hardware Contract* The hardware contract system bridges your **type**CAD hardware design with firmware development. It exports a JSON manifest describing which MCU pins are connected to what, enabling automatic firmware code generation. ## Overview A hardware contract is a JSON file that describes: - Which MCU is being used - Which pins are connected and to what nets - Available peripherals (I2C, SPI, UART) auto-detected from KiCAD pin names ## Usage ```ts import { PCB, Component } from '@typecad/typecad'; let pcb = new PCB('my_board'); let mcu = new Component({ symbol: 'MCU_Microchip_ATtiny:ATtiny3227-M', footprint: 'Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm', typehal: { pinLookup: { 1: 'PB5', 2: 'PB3', 5: 'PB0', // ... } } }); pcb.net(mcu.pin(5), sensor.SDA); pcb.net(mcu.pin(7), sensor.SCL); // After create, export the contract pcb.create(mcu, sensor); pcb.contract({ mcuReference: mcu.reference }); ``` ## Contract Output ```json { "version": 1, "mcu": { "symbol": "MCU_Microchip_ATtiny:ATtiny3227-M", "reference": "U1", "value": "", "footprint": "Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm", "mpn": "", "datasheet": "", "description": "" }, "connectedPins": { "5": { "pinName": "PA0", "pinType": "bidirectional", "boardName": "PB0", "net": "SDA", "externalComponents": [] }, "7": { "pinName": "PA2", "pinType": "bidirectional", "boardName": "PB2", "net": "SCL", "externalComponents": [] } }, "availablePeripherals": { "i2c": true, "spi": false, "uart": false } } ``` ## `typehal` Property The `typehal` property on `Component` provides pin mapping for contract generation: | Field | Description | |-------|-------------| | `pinLookup` | Mapping from IC pin numbers to board framework pin names | ## Peripheral Detection **type**CAD automatically detects available peripherals by analyzing KiCAD pin names. If a component has pins named `SDA` and `SCL`, I2C is detected. Pins named `MOSI`, `MISO`, `SCK`, and `CS` indicate SPI. `RX` and `TX` pins indicate UART. ## TypeHAL Integration The hardware contract is designed to work with TypeHAL, a firmware generation tool that can take the contract JSON and produce initialization code for your MCU. This enables a seamless flow from hardware design to firmware development. --- ## Import *Import from KiCAD* The `typecad import` command converts an existing KiCAD `.kicad_pcb` file into typeCAD TypeScript code. This is useful for importing existing designs or creating typeCAD packages from boards you've already laid out in KiCAD. ## Usage ```bash typecad import build/board.kicad_pcb ``` This will output TypeScript code snippets for: - **Component declarations** with positions (`pcb: { x, y, rotation }`) - **TrackBuilder objects** for all traces on the board - **Via definitions** with size, drill, and location - **Net names** extracted from the board ### Example Output ```ts // Components let c1 = new Capacitor({ value: '100nF', reference: 'C1', pcb: { x: 120.5, y: 85.3, rotation: 0 } }); let r1 = new Resistor({ value: '10kohm', reference: 'R1', pcb: { x: 135.2, y: 80.1, rotation: 90 } }); // Tracks this.pcb.track().from({ x: 120.5, y: 85.3 }, 'F.Cu', 0.25).to({ x: 135.2, y: 80.1 }); this.pcb.track().from({ x: 135.2, y: 80.1 }, 'F.Cu', 0.25).to({ x: 140.0, y: 80.1 }); // Vias this.pcb.via({ at: { x: 140.0, y: 80.1 }, size: 0.8, drill: 0.4 }); ``` ## Interactive Apply Mode Use `--apply` to interactively sync coordinates back to your source files: ```bash typecad import build/board.kicad_pcb --apply ``` In this mode, `kicad2typecad` will: 1. Read the PCB file 2. Match components against your existing typeCAD source 3. Show you the differences 4. Let you choose which coordinates to update in your source files This is especially useful when you've moved components in KiCAD and want to capture those changes in your typeCAD code. ## Variable Names Component variable names in the generated code are sourced from the footprint's `Code` property in KiCAD if available, falling back to the KiCAD reference designator (e.g., `C1`, `R1`). ## What Gets Imported - **Components** — footprints, positions, rotation, front/back side - **Tracks and vias** — as `pcb.track()` chains with nets - **Zones and rule areas** — filled pours as `pcb.zone()` (polygon geometry, fill settings via the grouped `fill` object) and keepouts as `pcb.keepout()` with their restrictions; unconnected pours import without a net - **Board outline** — rectangles, polygons, circles on `Edge.Cuts` - **Layer stackup** — as `pcb.stackup(N)` when the board declares one - **Text elements** — as `pcb.text()` calls ## Use Cases ### Package Creation The most common use case is creating [packages](/docs/package/overview). You can: 1. Lay out an entire circuit in KiCAD — components placed, tracks drawn, vias added 2. Run `typecad import` to generate the code snippets 3. Copy the snippets into your package's `index.ts` ### Importing Existing Designs If you have an existing KiCAD project, you can import it into typeCAD to get the benefits of code-based design while preserving your existing layout. --- ## Package Code *Code* Now that we've created a package, we need to know how to use it. ## Self-documenting A benefit of TypeScript is that you can write a lot of documentation in the code itself. You'll notice the JSDoc comments in the package code. This will result in VSCode hints and tips as you write your code, explaining parameters and providing examples if fully implemented. ## `import` The tooling gave us the `import` statement for the package. ```ts import { TypecadPackage } from "./typecad_package"; ``` ## `new` Now create a new instance of the package. `pcb`, `x`, and `y` are required: ```ts import { PCB } from '@typecad/typecad'; import { TypecadPackage } from "./typecad_package"; import * as _0805 from '@typecad/passives/0805' let typecad = new PCB('typecad_docs'); let u1 = new TypecadPackage({ pcb: typecad, x: 50, y: 50 }); let u2 = new TypecadPackage({ pcb: typecad, x: 100, y: 50, reference: 'U2' }); let u3 = new TypecadPackage({ pcb: typecad, x: 150, y: 50, passives: _0805 }); ``` Options: - _pcb_ — the PCB instance (required) - _x_ / _y_ — position on the board (required) - _reference_ — reference designator for the main IC - _name_ — name for the PCB group (defaults to the class name) - _passives_ — override the default 0603 passives factory ## Connections After creating the instance, you can access the pins of any component in the package: ```ts u1.ATtiny3227_M.GND // the ground pin of the ATtiny3227 u1.ATtiny3227_M.VCC // the power pin of the ATtiny3227 ``` ## Include the package After the package has been pulled in with an `import` and a `new` instance created, configuration is done, and connections made, you `create` it to the schematic. ```ts import { PCB } from '@typecad/typecad'; import { TypecadPackage } from "./typecad_package"; let typecad = new PCB('typecad_docs'); let u1 = new TypecadPackage({ pcb: typecad, x: 50, y: 50 }); typecad.create(u1.components); ``` The package's components will be added to the PCB. ## Do Not Populate If a package includes a component you don't want included in the netlist or layout: ```ts let u1 = new TypecadPackage({ pcb: typecad, x: 50, y: 50 }); u1.ATtiny3227_M.dnp = true; ``` --- ## Passives *Passives* To simplify adding components, the most common components: resistors, capacitors, etc, have been packaged into [@typecad/passives](https://www.npmjs.com/package/@typecad/passives). It is automatically installed when a project is created. ## Sizes The [@typecad/passives](https://www.npmjs.com/package/@typecad/passives) package is organized by component size. ```ts import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0805' let r1 = new Resistor({ value: '1kohm', reference: 'R1' }); ``` Will import all the components in the 0805 size. To import 0603 components, use: ```ts import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0603'// [!code word:0603:1] ``` All of the sizes are: - @typecad/passives/1210 - @typecad/passives/1206 - @typecad/passives/0805 - @typecad/passives/0603 - @typecad/passives/0402 - @typecad/passives/0201 **no fuses* ### Multi-sizes To import multiple sizes, use this `import` statement syntax: ```ts // [!code word:* as _0603] // [!code word:* as _0805] import * as _0603 from '@typecad/passives/0603' import * as _0805 from '@typecad/passives/0805' let r1 = new _0603.Resistor({ value: '1kohm' }); let c2 = new _0805.Capacitor({ value: '1uF' }); ``` > [!tip] > `_0603` and `_0805` can be changed to any TypeScript-legal name. ## Reference Designators KiCAD tracks components by their reference designator. This is the name that appears on the schematic and the PCB. In the `passives` package, the `reference` property is how components are referenced. It is not a required property of any `passives` component, if it is not passed, one will automatically generated. Auto-generation works as follows: - if `reference` is passed, it will be used. If there is a name conflict, it will be renamed and a warning will be logged in the build output. - if `reference` is not passed, it will create one using the `prefix` property and an internal counter by type of component. ie the first resistor will be `R1`, the second resistor will be `R2`, etc. - if the `prefix` property is not passed, it will be `R` by default for resistors, `C` for capacitors, `L` for inductors, etc. > [!warning] > Because ultimately, KiCAD is tracking components by reference designator, components will sometimes swap reference designators with each other based on when the **type**CAD build process encounters it during the build process. This only happens when a similar component is created before an already laid-out component. **This is avoided by only using one or the other: auto-generation or explicit reference passing.** ## Unique Footprints Sometimes, passive components will have a unique footprint. To use that footprint with this package: 1. copy the footprint file (.kicad_mod) into ./hw/src/build/lib/footprints 2. use it in your `new` component: ```ts import { Inductor } from '@typecad/passives/0805' let l1 = new Inductor({ value: '1uH', footprint: 'unique_inductor_footprint' }); ``` --- ## Pins *Pins* In **type**CAD, the `Pin` object represents the pin/leg/lead/ball etc. of a component. ## Pin Access Methods There are two ways to access pins in **type**CAD: ### Numeric Pin Access: `component.pin(number)` Use this for simple components like passives where pin numbers are straightforward: ```ts import { Resistor } from '@typecad/passives/0805' let r1 = new Resistor({ value: '1kohm' }); r1.pin(1); // first pin r1.pin(2); // second pin ``` ### Named Pin Access: `component.PINNAME` Use this for complex components (ICs, connectors) where pins have descriptive names and their own `.ts` file where `Pin` objects are defined: ```ts import { ATtiny85_20S } from './ATtiny85_20S'; let u1 = new ATtiny85_20S(); u1.VCC // power pin (internally pin 8) u1.GND // ground pin (internally pin 4) u1.PB0 // GPIO pin PB0 ``` ## Power aware Each `Pin` object has an optional `powerInfo` object that can be passed via the `component.pin()` config. It has the following properties: - `minimum_voltage` — minimum voltage the pin can tolerate - `maximum_voltage` — maximum voltage the pin can tolerate - `current` — maximum current the pin can handle When pins have the object passed with data, **type**CAD can check that the voltage levels and current draw are compatible with each other. ```ts VCC = this.pin(8, { type: 'power_in', powerInfo: { minimum_voltage: -0.5, maximum_voltage: 6, current: 0.2, }}); ``` `VCC` can accept -0.5 to 6 volts and supply up to 0.2 amps. When connected to other pins, **type**CAD can check that the voltage and current levels are compatible and issue error or warning messages if the voltage is too high or the current draw is too much. --- ## Power *Power* A `Power` object is extra information that is used for: - ERC: by setting `Pin` types to `power_out` or `power_in` - voltage compatibility checks - automatic trace width calculation via `powerInfo` A `Power` object represents a physical set of pins, not an abstract concept of power or ground. Options for the `Power` class are: - _power_ — pin that supplies power - _gnd_ — pin that supplies ground - _voltage_ — voltage of the power source - _current_ — current capacity - _direction_ — `'output'` (default) for power sources, `'input'` for power consumers ## How Pin Types Are Set When a `Power` object is created, pin types are set automatically for ERC: - The `power` pin is set to `power_out` when `direction` is `'output'`, or `power_in` when `direction` is `'input'`. - The `gnd` pin is **always** set to `power_in`, regardless of direction. Additionally, `voltage` and `current` are propagated to the pins' `powerInfo` property, which is used by ERC for voltage compatibility checks and by the routing system for automatic trace width calculation. ## Output `Power` An output `Power` object defines a source of electrical power within your design. If `direction` is omitted, it defaults to `'output'`. ```ts import { Component, Power } from '@typecad/typecad'; let bt1 = new Component({ footprint: 'Battery:BatteryHolder_Keystone_3008_1x2450' }); let coin_cell = new Power({ power: bt1.pin(1), // Pin 1 is the positive terminal → type set to 'power_out' gnd: bt1.pin(2), // Pin 2 is the ground terminal → type set to 'power_in' voltage: 3.7, // Nominal voltage current: 0.5, // Current capacity direction: 'output' // This is a power source (default) }); ``` In this example: - `bt1.pin(1)` gets `type: 'power_out'` and `powerInfo: { minimum_voltage: 3.7, maximum_voltage: 3.7, current: 0.5 }` - `bt1.pin(2)` gets `type: 'power_in'` and `powerInfo: { current: 0.5 }` ### Shared Ground Pins Components like voltage regulators often have both power inputs and outputs that share the same ground pin. Since the `gnd` pin is always set to `power_in` regardless of direction, this typically works without conflict. However, if you need to override the pin type for ERC purposes, you can set it manually: ```ts // U1 is a voltage regulator, pin 2 is shared ground let vin = new Power({ power: U1.pin(1), gnd: U1.pin(2), voltage: 5, direction: 'input' }); let vout = new Power({ power: U1.pin(3), gnd: U1.pin(2), voltage: 3.3, direction: 'output' }); // Both Power objects set U1.pin(2) to 'power_in', so no conflict here. // If needed, override manually: // U1.pin(2).type = 'passive'; ``` ## Input `Power` An input `Power` object specifies the power requirements for a component or sub-circuit. It is commonly passed into reusable packages so users can connect a suitable power source. ```ts // 'vin' is an input Power object passed as a parameter // U1 is a component within your design that needs power typecad.net(vin.power, U1.VCC); typecad.net(vin.gnd, U1.GND); ``` When `direction` is `'input'`, the `power` pin is set to `power_in` and the `gnd` pin is also set to `power_in`. ### Voltage checks A package can check that the voltage levels coming in are correct as well. ```ts if (vin.voltage != 3.3) { throw new Error('Voltage must be 3.3v'); } ``` --- ## Project Structure *Project Structure* A **type**CAD project is self-contained and looks like this: ```bash project ├── fw ├── hw │ └── build │ └── lib │ └── footprints └── src ``` ## `fw` Intended for firmware. If a PlatformIO project is created when you run `typecad create`, you can open the `workspace` file to open both the firmware and hardware projects in the same VSCode and have access to their respective build tools. ## `hw` All the hardware-related files are here. - `typecad.conf.ts` — configuration file (see [Configuration](/docs/configuration)) - `build` holds all the KiCAD files - `./build/lib` is where KiCAD symbols are stored - `./build/lib/footprints` is where KiCad footprints are stored - `src` is where the TypeScript files are stored Files under `./build/lib/` come from two sources: components you add locally via the **type**CAD CLI (`typecad add`), and any installed component packages. When a component package that bundles its own `./build/lib/` is used in a project, **type**CAD automatically syncs those bundled files into the project's `./build/lib/` directory the first time the `Package` is constructed during a build — no install script required. ## Self-contained The entire project is contained in the project folder. Symbols, footprints, 3d files, source files, etc. are all in this project folder. --- ## Requirements *Requirements* Make sure your system has the required software to get started. - [KiCAD](https://kicad.org/download/) - version **10.0** - [npm/Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) - version **20** or later - [Visual Studio Code](https://code.visualstudio.com/) - *not required, but highly recommended and used throughout this website* - [PlatformIO](https://docs.platformio.org/en/latest/core/installation/index.html) - *mentioned, but not required* - [git](https://git-scm.com/downloads) - *mentioned, but not required* - [ngspice](https://ngspice.sourceforge.io/download.html) - *optional, used for circuit simulations* --- > [!WARNING] pio and git in your PATH > Ensure that `pio` and `git` are in your PATH. **type**CAD optionally uses these commands in its tooling --- ## Tooling *Tooling* **type**CAD provides a unified CLI tool with a collection of commands to make the development process easier. All commands are accessed through the `typecad` binary, which is included when you install `@typecad/typecad`. ## `typecad create` To create a new project: ```bash typecad create ``` You'll be prompted to enter project details: - name for the project - if you want to create a PlatformIO project and if so, the [board ID](https://docs.platformio.org/en/latest/boards/index.html) - if you want to create a `git` repository - install optional utility packages A project will be created in the current directory. Inside the project directory, there will be a VSCode `workspace` file that will open the project in VSCode. ### Non-interactive mode All the information can be passed by command-line arguments and the script will automatically create a project. `--help` will show all the parameters. ```bash typecad create --name=typecad_project --git=false --pio=false ``` --- ## `typecad build` Builds your typeCAD project, running the TypeScript entry file and generating KiCAD output files. ```bash typecad build ``` The outputs will be in `./build/`. Use `--verbose` for detailed output. ## `typecad add component` Adds a component to the project. It is available as the `Add Component` script in VSCode's NPM Scripts sidebar. ```bash typecad add component ``` When the command runs, you'll be asked the source for the symbol and footprint files. You can mix any of the sources ie. a KiCAD symbol, but a local file. - If it's a KiCAD library component, you'll be prompted to enter the symbol and footprint names - If it's a local file, you'll be prompted to enter the path to the file - If it's an EasyEDA/JLCPCB component, you'll be asked for the `C###` number A `[component].ts` file will be generated along with instructions on how to use it. Files will also be copied into the `./build/` directory. ### Non-interactive mode ```bash typecad add component --symbol_source=kicad --footprint_source=local --symbol=MCU_Microchip_ATtiny:ATtiny3227-M --footprint=MyLib:MyFootprint typecad add component --symbol_source=jlcpcb --footprint_source=kicad --c=C3217148 --footprint=Package_QFN:QFN-32-1EP_5x5mm_P0.5mm_EP3.45x3.45mm ``` > [!important] > There's no need to add passives (resistors, capacitors etc.) this way. See the [Passives](/docs/passives) page for more information. ## `typecad add package` Creates a reusable **type**CAD package with all the boilerplate code. It sets up the package for easy publishing and reuse. It is discussed in more detail in the [Package Overview](/docs/package/overview) page. Execute in `./hw` of an already existing **type**CAD project. ```bash typecad add package ``` ### Non-interactive mode ```bash typecad add package --empty=true --name=my_package typecad add package --component=true --name=attiny_package --kicad=true --symbol=MCU_Microchip_ATtiny:ATtiny3227-M --footprint=Package_DFN_QFN:DFN-20-1EP_3x4mm_P0.5mm_EP1.65x3.1mm ``` ## `typecad search` Search KiCAD's symbol libraries with fuzzy matching: ```bash typecad search "attiny" typecad search "voltage regulator" --format=json --limit=10 ``` Results include symbol names, footprint suggestions, and component parameters. ## `typecad import` Convert an existing KiCAD `.kicad_pcb` file into typeCAD TypeScript code. Useful for importing existing designs. See [Import](/docs/import) for details. ```bash typecad import build/board.kicad_pcb ``` ## `typecad diff` Compare two KiCAD PCB files visually with layer-by-layer diff, netlist comparison, and BOM diff. See [Git Diff](/docs/gitdiff) for details. ```bash typecad diff board_v1.kicad_pcb board_v2.kicad_pcb typecad diff HEAD~1 ./build/board.kicad_pcb ``` ## `typecad doc` Generate HTML documentation from Markdown and KiCAD PCB files. Supports layer exports, 3D renders, and rich formatting. See [DocGen](/docs/docgen) for details. ```bash typecad doc docs/board.md build/board.kicad_pcb -o output.html ``` ## `typecad doctor` Check that your environment has all the required tools installed and properly configured. ```bash typecad doctor typecad doctor --fix typecad doctor --json ``` Use `--fix` to attempt automatic fixes, and `--json` for machine-readable output. ## `typecad validate` Validate your typeCAD source code without performing a full build. ```bash typecad validate typecad validate --verbose --json ``` ## `typecad drc` Run KiCAD's Design Rule Check as a passthrough to `kicad-cli`. The board-wide rules DRC validates against (minimum clearance, track width, via dimensions) default to the JLCPCB no-surcharge standard and are configurable in code — see [Board Layout → Design Rules](/docs/board_layout#design-rules). ```bash typecad drc ``` ## `typecad erc` Run KiCAD's Electrical Rules Check as a passthrough to `kicad-cli`. ```bash typecad erc ``` > [!note] Global options > All `typecad` commands support `--json` for machine-readable output, `--help` for usage info, and `--version` to check the version. --- ## Troubleshooting *Troubleshooting* Common errors and their solutions when working with typeCAD. ## Import and Module Errors ### "Cannot find module '@typecad/typecad'" **Cause**: Component created in wrong directory or `@typecad/typecad` not installed. **Solution**: 1. Ensure you're working in the `hw/` directory 2. Check that `hw/package.json` includes `@typecad/typecad` dependency 3. Run `npm install` in the `hw/` directory ### "Module has no exported member 'Connector'" **Cause**: Importing from wrong package path. ```ts // ❌ Wrong import { Connector } from '@typecad/passives/0603'; // ✅ Correct import { Connector } from '@typecad/passives/connector'; ``` ## Connection Errors ### "Property 'connect' does not exist on type 'Pin'" **Cause**: Using non-existent `.connect()` method. ```ts // ❌ Wrong pin1.connect(pin2); // ✅ Correct typecad.net(pin1, pin2); ``` ### "Property 'pin' does not exist" **Cause**: Using string-based pin access on components with named pins. ```ts // ❌ Wrong esp32.pin('VDD') // ✅ Correct esp32.VDD // or esp32.pin(8) if VDD is pin 8 ``` ## Component Creation Errors ### "Cannot find name 'ComponentName'" **Cause**: Component file not imported or created in wrong location. **Solution**: 1. Ensure component was created with `typecad add component` 2. Check the import statement matches the generated file 3. Verify component file is in `hw/src/` directory ### Component properties not working ```ts // ❌ Wrong new Connector({ pins: 3 }) // ✅ Correct new Connector({ number: 3 }) ``` Check the component documentation for correct property names. ## Build Errors ### TypeScript compilation errors 1. Check all imports are correct 2. Ensure all components are properly created with `typecad.create()` 3. Verify pin connections use correct syntax ### KiCAD file generation issues 1. Ensure all components have valid symbols and footprints 2. Check that all nets have at least 2 pins connected 3. Verify component references are unique ## Getting Help If you're still stuck: 1. Check the [Examples](/examples) for working code patterns 2. Join the [Reddit community](https://www.reddit.com/r/typecad/) 3. Review the [API documentation](/docs) for correct syntax --- ## What Is Typecad *What is typeCAD* ## KiCAD + TypeScript + npm = **type**CAD > typeCAD is a way to programmatically create hardware designs. It's done with TypeScript and all the awesomeness of the npm/Node.js ecosystem. - npm packages can be imported into your projects - create portable/importable/shareable packages - semantic version control The schematic portion of hardware design is replaced with a few simple TypeScript classes. Rather than clicking and dragging, a line of code creates a component, and another line connects it. Sections of code can be turned into reusable modules and those modules can be turned into reusable packages, layout included. Code can be version controlled, status tracked, git push/pull/PR/issues can be used, and all the typical tools for software design can be used for hardware design now ## Example This **type**CAD code... ```ts import { PCB, Component } from '@typecad/typecad' import { Resistor, LED } from '@typecad/passives/0805' let typecad = new PCB('typecad'); let bt1 = new Component({ footprint: 'BatteryHolder_Keystone_500' }); let r1 = new Resistor({ value: "1 kOhm" }); let d1 = new LED(); typecad.named('vin').net(bt1.pin(1), r1.pin(1)); typecad.net(r1.pin(2), d1.pin(2)); typecad.named('gnd').net(d1.pin(1), bt1.pin(2)); typecad.create(r1, d1, bt1); ``` ...is the same as this schematic. ![simple led circuit](https://typecad.net/led.png) >The difference is that code can be copied, turned into reusable packages, version controlled, and used within the npm/Node.js system. ## Get started Read through the [walkthrough](https://typecad.net/docs/walkthrough/get-started) for a quick introduction to the basics. Wouldn't testing and CI be nice for hardware designs? Code can be version controlled, status tracked, git push/pull/PR/issues can be used, and all the typical tools for software design can be used for hardware design now. ```ts expect(power.minimum).to.be.at.least(3.0); // check voltage levels expect(power.maximum).to.be.at.most(3.6); typecad.erc(); // run ERC on every build ``` --> --- ## Examples *Examples* ### Tutorial | | | | :------------------------------------------------ | ------------------------------- | | [Creating a project](/getting-started) | creating and building a project | | [Add/connect passives](/examples/voltage-divider) | make a voltage divider | | [Add KiCAD Components](/examples/attiny85) | Add an MCU to your project | | [Use typeCAD Packages](/examples/packages) | Add a typeCAD package | ### Examples A list of small examples to show how to use **type**CAD | | | | :--------------------------------------- | -------------------------------------------------- | | [ERC](/examples/erc) | run an electrical rule check on your schematic | | [BOM](/examples/bom) | export a bill-of-material file from your schematic | | [ngspice](/examples/ngspice) | run a simulation with your **type**CAD code | | [JLCPCB-Export](/examples/jlcpcb-export) | export all the assembly files for JLCPCB | | [Jig/Multi-boards](/examples/jig) | Create a test jig/multi-board with one codebase | | [Auto Router](/examples/autorouter) | Auto-route tracks between connected pins | | [Multilayer Boards](/examples/multilayer-board) | 4+ layer boards: planes, impedance control, via policy | | [Zones](/examples/zones) | Create copper zones and keepout areas | | [Visual PCB Diff](/examples/gitdiff) | Compare two KiCAD PCB files visually | | [Documentation Gen](/examples/docgen) | Generate HTML docs from Markdown + KiCAD PCB | | [Import KiCAD Board](/examples/import-kicad) | Convert a KiCAD PCB to typeCAD code | --- ## Attiny85 *Adding KiCAD Library Components* **type**CAD is tightly integrated with KiCAD, that means easy access to the installed KiCAD library of parts it comes with. ### Video ## `add-component` Using the `Add Component 🧩` NPM script to add a new component is the easiest way. It should be available to just click in the NPM Scripts section in VS Code. There are three sources of components: KiCAD, JLCPCB and local files. Both symbol and footprint files are needed to create a typeCAD component. Any source can be mixed with any other, ie. a KiCAD symbol and a local downloaded footprint. Click it and you should see something like the following: ``` 🧩 typeCAD Create Component ? Select symbol source: (Use arrow keys) ❯ KiCAD local file EasyEDA/JLCPCB A symbol from the installed KiCAD library ``` Choose `KiCAD` for both symbol and footprint source. The next thing it asks is the `Symbol name`. Right now, the easiest way to get that information is to add the part you want to a schematic. For this example, we'll make an ATtiny85 MCU. Open KiCAD's schematic editor and add it to a KiCAD schematic. Select it and press `e`. You should see a dialog that looks like this: ![KiCAD Symbol Properties](/docs/attiny85.png) The highlighted `Library link` text on the bottom has the information you need. The first part, before the `:` is the symbol library name (`MCU_Microchip_ATtiny`), the second part is the symbol name (`ATtiny85-20S`). KiCAD conveniently lets you copy this text, so copy it and paste it into our terminal. ``` 🧩 typeCAD Create Component ✔ Select symbol source: KiCAD ✔ Select footprint source: KiCAD ✔ Symbol name? MCU_Microchip_ATtiny:ATtiny3227-M ? Footprint name? (Package_DFN_QFN:QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm) ``` The next question asks for the `Footprint name`. For KiCAD components, the default text will contain the symbol-specified footprint file. For some components this might not be what you want, but for this particular component, `Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm` is the right one. Hit enter. Footprints are defined in the sam way as symbols ([footprint_lib:footprint_name]). ``` 🧩 typeCAD Add Component ✔ Select symbol source: KiCAD ✔ Select footprint source: KiCAD ✔ Symbol name? MCU_Microchip_ATtiny:ATtiny85-20M ✔ Footprint name? Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm Finished component creation, use it with: import { ATtiny85_20M } from './ATtiny85_20M'; let u1 = new ATtiny85_20M(); ``` There will be a little implementation code that shows how to `import` the code and create a `new` instance of it. ## `import` The minimal code to use this new component looks like this: ```ts import { PCB } from '@typecad/typecad' import { ATtiny85_20M } from './ATtiny85_20M'; let typecad = new PCB('attiny85'); let u1 = new ATtiny85_20M(); typecad.create(u1); ``` --- ## Autorouter *Auto Router* The **type**CAD auto router generates tracks between connected pins using A* pathfinding. It respects obstacles, supports multi-pin nets, and can be configured for different grid resolutions. ## Basic Usage ```ts import { PCB } from '@typecad/typecad'; import { Resistor, Capacitor } from '@typecad/passives/0603'; let pcb = new PCB('autorouter_example'); let r1 = new Resistor({ value: '1kohm', pcb: { x: 10, y: 10, rotation: 0 } }); let r2 = new Resistor({ value: '1kohm', pcb: { x: 20, y: 10, rotation: 0 } }); let c1 = new Capacitor({ value: '100nF', pcb: { x: 15, y: 15, rotation: 0 } }); const signal_net = pcb.named('signal').net(r1.pin(1), r2.pin(1)); const bypass_net = pcb.named('bypass').net(c1.pin(1), r1.pin(2)); pcb.route(signal_net); pcb.route(bypass_net); pcb.create(r1, r2, c1); ``` ## Configuration Options ```ts pcb.route(signal_net, { gridResolution: 0.15, // Grid cell size in mm debug: false, // Enable detailed logging }); ``` ## How It Works 1. **Grid Generation**: A routing grid is constructed covering the area occupied by components 2. **Obstacle Mapping**: Pad geometries and existing tracks are mapped as obstacles 3. **Path Search**: For multi-pin nets, a Minimum Spanning Tree (MST) determines connection order, then A* finds the shortest path for each edge 4. **Track Generation**: Valid paths are converted into track segments in the board file ## Batch Autorouting Route all unconnected nets at once: ```ts pcb.route(signal_net); pcb.route(bypass_net); pcb.route(power_net); // All routes are computed together pcb.create(r1, r2, c1); ``` ## Power-Aware Routing Use `Power` objects with tracks to ensure adequate trace width: ```ts import { PCB, Power } from '@typecad/typecad'; let pcb = new PCB('power_example'); let power = new Power({ power: regulator.pin(3), gnd: regulator.pin(2), voltage: 3.3 }); const vcc_net = pcb.named('VCC').net(regulator.pin(3), mcu.VCC); pcb.route(vcc_net); ``` The router considers power info when determining appropriate trace widths. --- ## Bom *BOM* **type**CAD provides a built in BOM export function. ## Bill-of-Material **type**CAD can export a CSV file from a `Schematic` object. ```ts import { Component, PCB, Power } from '@typecad/typecad'; let typecad = new PCB('bom'); // add components typecad.create(); typecad.bom(); ``` The output will be a `bom.csv` in the `./build` folder and will look something like this: ```csv Reference,Value,Datasheet,Footprint,MPN U1,,,lib:ESP32S3MINI1N8,C2913206 C3,22uF,,Capacitor_SMD:C_0603_1608Metric, C4,0.1uF,,Capacitor_SMD:C_0603_1608Metric, C6,1uF,,Capacitor_SMD:C_0603_1608Metric, R2,10kΩ,,Resistor_SMD:R_0603_1608Metric, C1,22uF,,Capacitor_SMD:C_0603_1608Metric, C2,10uF,,Capacitor_SMD:C_0603_1608Metric, VR1,,https://www.mouser.com/datasheet/2/698/REN_isl9120ir_DST_20050421-1998698.pdf,lib:QFN50P300X300X75-13N-D,ISL9120IRTNZ L1,1uH,https://www.mouser.com/datasheet/2/281/1/J_E_TE243A_0011-2303275.pdf,lib:1285ASH1R0MP2,1285AS-H-1R0M=P2 BT1,,,Battery:BatteryHolder_Keystone_3008_1x2450,3008TR ``` Each field, `value`, `datasheet`, `footprint`, and `MPN` can all be set for each `Component` object. ## Extending BOM **type**CAD is entirely TypeScript, so you can extending or changing the function is simple. You'll want to look at how the BOM function is implemented in [schematic.ts](https://github.com/typecad/typecad/blob/1a63964eece0fc98053e426192e770c35577a14d/schematic.ts#L96). This is the bulk of the function and is simple to change. ```ts bom += 'Reference,Value,Datasheet,Footprint,MPN\n'; this.components.forEach(component => { bom += `${component.reference},${component.value},${component.datasheet},${component.footprint},${component.mpn}\n`; }); ``` --- ## Docgen *Documentation Generation* The `typecad doc` command generates self-contained HTML documentation from a Markdown file combined with a KiCAD PCB file. It automatically embeds PCB layer images, 3D renders, and other visuals. ## Basic Usage ```bash typecad doc docs/board.md build/board.kicad_pcb -o docs/board.html ``` ## Creating Your Document Create a Markdown file with frontmatter and content: ```text --- title: Sensor Board Documentation company: Acme Corp board_name: SensorBoard revision: "1.0" --- # Sensor Board Documentation ## Top Copper Layer ![{F.Cu}](top_copper.svg =600) ## Bottom Copper Layer ![{B.Cu}](bottom_copper.svg =600) ## Component Placement ![{F.SilkS,F.Mask}](placement.svg =600) ## 3D View ![{Render/30/45/0}](render.png) ## Schematic Notes The board uses an ATtiny3227 MCU with I2C-connected sensors. ``` ## Layer Export Syntax Use custom image syntax to reference PCB layers: | Syntax | Description | |--------|-------------| | `![{F.Cu}](out.svg)` | Front copper layer | | `![{F.Cu,F.Mask}](out.svg =600)` | Multiple layers combined | | `![{B.Cu}](out.svg)` | Bottom copper layer | | `![{F.SilkS}](out.svg)` | Front silkscreen | | `![{Edge.Cuts}](out.svg)` | Board outline | | `![{Render/30/45/0}](out.png)` | 3D render with rotation | | `![{Drill}](out.svg)` | Drill map | | `![{Stackup}](out.svg)` | Layer stackup diagram | ## Assembly Documentation A common use case is generating assembly documentation: ```bash typecad doc assembly.md build/sensor_board.kicad_pcb -o build/assembly-docs.html ``` This creates a shareable, self-contained HTML file with all images embedded — perfect for sending to manufacturers or archiving. --- ## Erc *ERC* **type**CAD provides ERC via the `typecad erc` CLI command and the `runERC()` programmatic API. ## Electrical Rules Checker **type**CAD runs KiCAD's ERC via `kicad-cli sch erc`. After `typecad build` has been run, you can run `typecad erc` to check your schematic for any connection errors. It uses the same KiCAD rules as shown in this picture. ![KiCAD ERC](/examples/erc/kicad-erc.png) KiCAD includes a lot of other rules, but the majority of them are not relevant to **type**CAD. Here's how to run ERC from the command line: ```bash typecad build typecad erc ``` Assuming no errors, it will show `ERC passed. No errors or warnings.` in the output. You can also run ERC programmatically: ```ts import { runERC } from '@typecad/typecad'; let report = await runERC('./build/erc.kicad_sch'); console.log(report); ``` > [!WARNING] > If ERC returns an error, the build process is stopped. The code under `::erc` will not be executed. ## Pin Types ERC works primarily by checking pin type against each other. The types are the standard KiCAD pin types: `power_in`, `power_out`, `passive` etc. A `power_in` pin must be connected to a `power_out` pin, for example. Pin type are typically set in [component](/docs/components) files, generated by **type**CAD tooling. The information for pin types is taken from the symbol files, but the files are not always correct. Many symbols that come from outside the KiCAD library will have all the types set to `passive`. Pin types can be corrected manually in the component files, or they can be set in code like this: ```ts import { Component } from '@typecad/typecad'; let bt1 = new Component({ footprint: 'Battery:BatteryHolder_Keystone_3008_1x2450', prefix: 'BT', mpn: '3008TR' }); bt1.pin(1).type = 'power_out'; bt1.pin(2).type = 'power_out'; ``` This example shows changing a battery holder's pins to `power_out` since they were set to `passive` originally. --- ## Gitdiff *Visual PCB Diff* The `typecad diff` command lets you visually compare two KiCAD PCB files with an interactive HTML report showing layer-by-layer differences, netlist changes, and BOM differences. ## Basic Usage Compare two PCB files: ```bash typecad diff build/board_v1.kicad_pcb build/board_v2.kicad_pcb ``` This generates an HTML report and opens it in your browser. The report shows each PCB layer with changes highlighted in color. ## Git Revision Comparison Compare against a previous git commit: ```bash # Compare last commit vs current file typecad diff HEAD~1 ./build/board.kicad_pcb # Compare two specific commits typecad diff v1.0.0 HEAD -- board.kicad_pcb ``` This is useful for code reviews — see exactly what changed on the PCB between revisions. ## Full Comparison By default, only changed layers are included. Use `--full` to include all layers: ```bash typecad diff --full board_v1.kicad_pcb board_v2.kicad_pcb ``` ## What You'll See The report includes: 1. **Visual layer diff**: Each copper, mask, silkscreen, and courtyard layer with changes highlighted 2. **Netlist comparison**: Added, removed, and modified nets 3. **BOM comparison**: Added, removed, and changed components 4. **Interactive viewer**: Side-by-side, overlay, onion skin, swipe, and diff-only modes ## In a CI/CD Pipeline Add diff to your CI to automatically generate visual reports: ```bash # Generate diff report without opening it typecad diff HEAD~1 build/board.kicad_pcb --output diff-report.html ``` --- ## Import Kicad *Import a KiCAD Board* The `typecad import` command converts an existing KiCAD `.kicad_pcb` file into typeCAD TypeScript code. This is useful for importing existing designs or extracting layout information. ## Basic Import ```bash typecad import build/board.kicad_pcb ``` This outputs TypeScript code for all components, tracks, and vias found on the board. ## Using the Output The generated code can be used directly in your typeCAD project or in a [package](/docs/package/overview): ```ts // Paste the output into your package's index.ts // Components with positions from the PCB let c1 = new Capacitor({ value: '100nF', reference: 'C1', pcb: { x: 120.5, y: 85.3, rotation: 0 } }); let r1 = new Resistor({ value: '10kohm', reference: 'R1', pcb: { x: 135.2, y: 80.1, rotation: 90 } }); // Tracks this.pcb.track().from({ x: 120.5, y: 85.3 }, 'F.Cu', 0.25).to({ x: 135.2, y: 80.1 }); // Vias this.pcb.via({ at: { x: 140.0, y: 80.1 }, size: 0.8, drill: 0.4 }); ``` ## Interactive Apply Use `--apply` to sync coordinates from KiCAD back to your source files: ```bash typecad import build/board.kicad_pcb --apply ``` This will: 1. Match components in the PCB against your existing source code 2. Show coordinate differences 3. Let you choose which to update This is useful after moving components in KiCAD and wanting to capture those changes in code. ## Typical Workflow for Package Creation 1. Design your circuit in **type**CAD 2. Build and open in KiCAD: `typecad build` 3. Lay out the package in KiCAD — place components, draw tracks, add vias 4. Import the layout back: `typecad import build/board.kicad_pcb` 5. Copy the generated code into your package --- ## Jig *Test jig/multi-board creation* Making a test jig is a common activity when developing a PCB. Using **type**CAD, you can create a test jig and the board you're developing in a single codebase. This is also a demonstration of how multiple PCBs can be created from code as well. ## Testing jigs For this example, our board and jig will be: 1. a board with test points on the bottom 2. another board with pogo pins that connect to the test points 3. the boards will connect with standoffs and mounting holes There's obviously a lot of options here and this is just a simple example of one way it could be done. ## Make a **type**CAD project From a terminal, run: ```bash typecad create ``` Call this project `jig`. No need to make a PlatformIO project or initialize a git repo unless you want to. No extra packages are needed either, but feel free to add them later if you want. ## Code Add some code which will: - create a board with two test points and two mounting holes - create a jig board with two pogo pins and two mounting holes - add a resistor to pretend to be testing something ```ts import { PCB } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { MountingHole } from '@typecad/passives/mounting_hole'; import { Testpoint } from '@typecad/passives/testpoint'; import { P70_5000045R } from './P70_5000045R'; let typecad = new PCB('main'); let r1 = new Resistor({ value: '1kohm', pcb: {x: 166.815, y: 86.36, rotation: 0} }); let mh1 = new MountingHole({ size: 'M2.5', pcb: {x: 152.4, y: 76.2, rotation: 0} }); let mh2 = new MountingHole({ size: 'M2.5', pcb: {x: 177.8, y: 101.6, rotation: 0} }); let tp1 = new Testpoint({ pcb: {x: 165.1, y: 81.28, rotation: 0} }); let tp2 = new Testpoint({ pcb: {x: 168.04, y: 93.98, rotation: 0} }); typecad.create(r1, mh1, mh2, tp1, tp2); let jig = new PCB('jig'); let pogo1 = new P70_5000045R({ pcb: {x: 165.1, y: 81.28, rotation: 0} }); let pogo2 = new P70_5000045R({ pcb: {x: 168.04, y: 93.98, rotation: 0} }); jig.create(mh1, mh2, pogo1, pogo2); ``` ## Code walkthrough ### `import` ```ts import { PCB } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { MountingHole } from '@typecad/passives/mounting_hole'; import { Testpoint } from '@typecad/passives/testpoint'; import { P70_5000045R } from './P70_5000045R'; ``` We import the usual classes, plus a pogo pin from a custom package (_there's a downlink link at the bottom for this whole project_). `MountingHole`, `Testpoint` and `Resistor` are all from the `@typecad/passives` package which should already be installed. ### `PCB` Now create the two PCBs. ```ts let typecad = new PCB('main'); let jig = new PCB('jig'); ``` Here, we create the main board, and also the jig board. ### Components Then all the components are created. `mh1`, `mh2` are mounting holes. `tp1`, `tp2` are test points and will go on the main PCB. `pogo1`, `pogo2` are pogo pins and will go on the jig board. One important point to see is that the locations are being specified. This will come in handy when we reuse the mounting holes on the jig board. Now create the components on the main board. ```ts pcb.create(r1, mh1, mh2, tp1, tp2); ``` ### Jig board components The last thing to do will be to add the mounting holes and pogo pins to the jig board. Notice that we've copied the xy locations of the test points to the pogo pins. This will ensure that the pogo pins line up with the test points. ```ts let pogo1 = new P70_5000045R({ pcb: {x: 165.1, y: 81.28, rotation: 0} }); let pogo2 = new P70_5000045R({ pcb: {x: 168.04, y: 93.98, rotation: 0} }); jig.create(mh1, mh2, pogo1, pogo2); ``` ## Build Build the code and there will be two PCB files created; `main.kicad_pcb` and `jig.kicad_pcb`. You'll see that the mounting holes, testpoints/pogo pins all line up. From here you can add additional functionality as needed. Changes made to one board can be programmatically applied to the other board with just a little bit of code. ## Downlink [jig project source](/examples/jig/jig.zip) Extract the zip file and open `jig.code-workspace` in VSCode. `npm i` to install dependencies. --- ## Jlcpcb Export *JLCPCB-Export* The [@typecad/jlcpcb-export](https://www.npmjs.com/package/@typecad/jlcpcb-export) package exports all the assembly files for JLCPCB. Install the package in a **type**CAD project: ```ts npm i @typecad/jlcpcb-export ``` Then `import` it and use it: ```ts import { PCB } from '@typecad/typecad'; import { jlcpcb_export } from '@typecad/jlcpcb-export';// [!code highlight] let typecad = new PCB('project'); // all your code jlcpcb_export(typecad, pcb);// [!code highlight] ``` ## Pre-checks The most appropriate place to run `jlcpcb_export` may not be at the bottom of your code. This would work nicely in a Github CI/CD setup. When an update is pushed, the build files are created. Another option would be running it as a git hook. Regardless of where you run it, it will check: - that the board passes KiCAD's DRC - that the git repo is clean If you don't care, you can disable these checks: `jlcpcb_export(typecad, pcb, true);` ## Output Several files will be created, with a single zip file ready to upload to JLCPCB. --- ## Multilayer Board *Multilayer Boards* **type**CAD treats the copper layer count as a first-class property of the board. Declare it once and everything derives from it: the stackup that gets written to the `.kicad_pcb`, the layers the autorouter uses, where through-hole pads exist, and which layer references are valid. This example builds a typical 4-layer board — ground and power planes on the inner layers, an impedance-controlled bus, and budget-fab-friendly vias. ## Declare the stack Pass `layers` to the PCB constructor. That single number is the source of truth: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('sensor_board', { layers: 4 }); pcb.copperLayers; // ['F.Cu', 'In1.Cu', 'In2.Cu', 'B.Cu'] ``` Components go on the outer layers as usual. Routing defaults to every declared copper layer, so inner layers are used without any extra configuration. To control the physical construction — dielectric thicknesses, materials, dielectric constants — call `pcb.stackup()` with per-layer overrides: ```ts pcb.stackup(4, { layers: { 'dielectric 1': { thickness: 0.21, epsilon_r: 4.4 }, 'dielectric 2': { material: 'Rogers 4350B', epsilon_r: 3.48, loss_tangent: 0.0037 }, }, }); ``` Any dielectric budget left over is redistributed across the non-overridden layers, so the board still totals `pcb.thickness` (1.6mm by default). ## Dedicate the inner layers to planes `pcb.plane()` turns a copper layer into a power or ground plane. At `create()` each plane becomes a board-covering filled zone on its layer, and the autorouter stops routing signals there: ```ts pcb.outline(0, 0, 60, 45); // plane extent comes from the outline pcb.plane('GND', 'In1.Cu'); pcb.plane('+3V3', 'In2.Cu'); ``` The plane extent comes from the board outline, so call `pcb.outline()` before `create()`. SMD pads reach a plane through vias; through-hole pads connect solidly. ## Route at a controlled impedance With the planes owning the inner layers, signals route on F.Cu/B.Cu by default. Pass an `impedance` constraint and the autorouter widens the trace to hit the target — computed from the board's stackup geometry (microstrip on outer layers, symmetric stripline on inner ones): ```ts // check a width without routing: pcb.impedanceWidth('F.Cu', 50); // width in mm for 50Ω on this stackup // autoroute with impedance control (the trace only ever widens, // never below the design-rule floor) pcb.route(spi_clk, { impedance: { target: 50, tolerance: 5 } }); ``` ## Going deeper: signal layers between planes On a 6-layer board you can put signal layers between two ground planes — the classic stack for a fast bus. Net classes claim the preferred layer, and the impedance target is computed as stripline between the planes: ```ts let pcb = new PCB('fast_board', { layers: 6 }); pcb.outline(0, 0, 60, 45); pcb.plane('GND', 'In1.Cu'); pcb.plane('+3V3', 'In3.Cu'); pcb.plane('GND', 'In4.Cu'); // the memory bus lives on the inner signal layer pcb.netClass('mem', { layers: ['In2.Cu'] }); pcb.assign(dq0, 'mem'); // stripline impedance, computed from this stackup pcb.route(dq0, { impedance: { target: 50, tolerance: 5 } }); ``` ## Control via manufacturing By default every via the autorouter places is a through via (F.Cu→B.Cu) — always manufacturable at budget fabs. If your fab does blind/buried vias, opt in: ```ts // router vias use the exact layer pair a route transitions // between, up to 2 layer boundaries; deeper transitions fall // back to through vias, and via cost scales with span depth pcb.viaPolicy({ type: 'blind-buried', maxSpan: 2 }); ``` ## Create the board ```ts pcb.route(spi_clk, { impedance: { target: 50, tolerance: 5 } }); pcb.route(spi_mosi); pcb.route(spi_miso); // tie the outer ground pours to the GND plane with a via grid, // and reinforce every router via with teardrops pcb.teardrops(); pcb.zone({ net: 'GND', layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 60, height: 45 }); pcb.stitch('GND', { pitch: 1.5 }); pcb.create(); ``` When the board is written, every layer reference — zones, keepouts, vias, routes — is validated against the declared layer set. Referencing `"In3.Cu"` on this 4-layer board fails with an error telling you exactly what to change, instead of producing a broken `.kicad_pcb`. ## Complete example ```ts import { PCB } from '@typecad/typecad'; // 4-layer board: signals outside, GND and +3V3 inside let pcb = new PCB('sensor_board', { layers: 4, thickness: 1.6 }); pcb.stackup(4, { layers: { 'dielectric 2': { thickness: 1.1, epsilon_r: 4.5 } }, }); pcb.outline(0, 0, 60, 45); pcb.plane('GND', 'In1.Cu'); pcb.plane('+3V3', 'In2.Cu'); // components and nets (see the other examples) pcb.add(mcu, sensor, regulator, connector); const spi_clk = pcb.named('SPI_CLK').net(mcu.SCK, sensor.SCK); // ... pcb.teardrops(); pcb.route(spi_clk, { impedance: { target: 50, tolerance: 5 } }); pcb.route(spi_mosi); pcb.route(spi_miso); pcb.route(sensor_int); // ground pours on the outer layers, stitched to the plane pcb.zone({ net: 'GND', layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 60, height: 45 }); pcb.stitch('GND', { pitch: 1.5 }); pcb.create(); ``` --- ## Ngspice *ngspice* One of the benefits of PCB-as-code is it avoids the tediousness of drag-and-drop GUIs. The various spice simulations often require the same drag-and-drop steps and maybe even recreating the PCB. **type**CAD lets you use your code with only very minor changes. ## Voltage Divider This example will use the [voltage divider](/examples/voltage-divider) example as a starting point. This is the circuit: ![Voltage Divider](/examples/voltage-divider/voltage-divider.png) And this is the code: ```ts import { PCB } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ``` ## Install `@typecad/ngspice` First, make sure you have `@typecad/ngspice` installed in your project. From the `./hw` directory, run: ```bash npm install @typecad/ngspice ``` Then you'll need [ngspice](https://ngspice.sourceforge.io/download.html) installed and ensure the binaries are in your `PATH`. ### `Power` Next, we need to add a `Power` component. In addition to helping with simulation, they assist with ERC (electrical rule checking) by ensuring pins are connected as they should be and packages can use it to determine the power supply voltage is correct. ```ts import { PCB } from "@typecad/typecad" // [!code --] import { PCB, Power } from "@typecad/typecad" // [!code ++][!code word:Power] import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); let vin = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 3.3 }); // [!code highlight] typecad.named('in').net(r1.pin(1)); // [!code highlight] typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.named('gnd').net(r2.pin(2)); // [!code highlight] typecad.create(r1, r2); ``` In the code above, we added a `Power` object called `vin`. Power is coming in from the top of `R1` and going to the bottom of `R2`. The `voltage` is 3.3 volts. A more practical example would be a battery holder with the pins corresponding to the positive and negative terminals, but for this example, we'll use the resistor legs as the power terminals. > [!tip] > `Power` objects represent a physical component like the pins of a battery holder or a voltage regulator. It is not the same as a PCB `VCC` or `GND` symbol that is more abstract. Look at lines 10 and 12. You'll see that `vin.power` is connected to `r1.pin(1)` by itself and it is `::named`. `@typecad/ngspice` only pays attention to `::named` nets that have components used in the simulation. nspice will treat each `::named` net as a node and give voltage/power/current measurements for each. ## Import `ngspice` Now we need to add the `ngspice` related code. ```ts // [!code word:simulation] import { PCB, Power } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { ngspiceSimulator } from '@typecad/ngspice'; // [!code highlight] let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm', simulation: { include: true } }); let r2 = new Resistor({ value: '10kohm', simulation: { include: true } }); let vin = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 3.3 }); let ngspice = new ngspiceSimulator(typecad, vin); // [!code highlight] typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ``` This code imports the package. It also adds a `simulation` property to the resistors. This tells `@typecad/ngspice` to include the component in the simulation. Every component has a `simulation` property, setting `include` to `true` will include the component in the simulation. There is an additional property, `model`, that can be used to specify an ngspice model: `{model: '.model Dled D (IS=1a RS=3.3 N=1.8)'`. The last thing is to create a `ngspiceSimulator` object. It takes the `PCB` object and all the `Power` objects. In this example, we only have one `Power` object, but if you have multiple, you can pass them all. ## Simulate Now that our circuit is created, nets are named, we can run the simulation. Currently, there are two simulation modes available in the library: DC and transient analysis. ```ts import { PCB, Power } from "@typecad/typecad" import { Resistor } from '@typecad/passives/0603'; import { ngspiceSimulator } from '@typecad/ngspice'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm', simulation: { include: true } }); let r2 = new Resistor({ value: '10kohm', simulation: { include: true } }); let vin = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 3.3 }); let ngspice = new ngspiceSimulator(typecad, vin); typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ngspice.op(); // [!code highlight] ``` When the project is built, the output will be in the console: ```bash 🌶️ Running ngspice ┌────────────────────┬───────────────┬────────────────────┐ │ Variable │ Type │ Value │ ├────────────────────┼───────────────┼────────────────────┤ │ r1:power │ power │ 2.7225 mW │ ├────────────────────┼───────────────┼────────────────────┤ │ v(in) │ voltage │ 3.3000 V │ ├────────────────────┼───────────────┼────────────────────┤ │ i(r1) │ current │ 1.6500 mA │ ├────────────────────┼───────────────┼────────────────────┤ │ i(r2) │ current │ 1.6500 mA │ ├────────────────────┼───────────────┼────────────────────┤ │ r2:power │ power │ 2.7225 mW │ ├────────────────────┼───────────────┼────────────────────┤ │ i(v1) │ current │ -1.6500 mA │ ├────────────────────┼───────────────┼────────────────────┤ │ v(vdiv) │ voltage │ 1.6500 V │ └────────────────────┴───────────────┴────────────────────┘ ``` Each node will be displayed with calculated voltage. ngspice doesn't list ground nodes. Each included component will be displayed with power and current. The final bit will be information about the power supply. In this example, `v1` supplies 1.65 mA of current to the circuit. ### Transient This example won't show any variance, but you can run a transient analysis. Add `ngspice.tran('1us', '100ms');` to the end of the file and ngspice's graphing windows will open for all the nodes and components when the project is built. `tran` takes all the same arguments as ngspice's `tran` command, as described in the [ngspice documentation](https://ngspice.sourceforge.io/docs/ngspice-manual.pdf), section 11.3.10. ## Continuing development This package covers the basic functionality of basic components. Future development will include the ability to use ngspice library files, additional power source options, and more analysis types. --- ## Packages *Adding typeCAD Packages* **type**CAD is just code and code can be easily packaged and distributed. Read more about them at their [doc](/docs/package/overview) page, but quickly they allow for easy packaging/installation/reuse of blocks of code. A particularly useful thing is implementing a particular IC, including all the passives, connections, and tracks to use it. The result is simply importing packages and connecting them together. Since a package is entirely defined by the package itself and what it does, there is no _one way_ to use them, so each package comes with its own documentation. ## `@typecad/rd-bq24210` There is a [package](https://www.npmjs.com/package/@typecad/rd-bq24210) available that implements the [bq24210](https://www.ti.com/lit/ds/symlink/bq24210.pdf), a solar-powered battery charger. Let's add it to an existing project. ### `npm i` Run `npm i @typecad/rd-bq24210` in your project's `./hw` directory. It will install all the required files including KiCAD symbols, footprints and 3d models into the project's `./build/lib` directory. > [!WARNING] > When using any `npm` command, ensure it is entered in the `./hw` directory, at the same level as the `package.json` file is. If it is given in another folder, it either won't work, or will create a bunch of unwanted folders. ### `import` The package's page gives implementation code: ```ts import { rd_bq24210 } from '@typecad/rd-bq24210'; ``` ### `new` Create a new instance: ```ts ... let charger = new rd_bq24210({ chargeCurrentMa: 500, temperatureMonitoring: true, pcb: typecad }); ... ``` According to the package documentation, there are a couple things that can be configured in this step: the charging current and using temperature monitoring. Charging current is determined by a simple formula that results in a resistor value connected to the IC, the package does the calculations and returns a resistor value to provide the specified current. ### `create` The package has a property, `::components` which includes all `create`-able elements. This can be passed directly to your `PCB::create()` method. ```ts ... typecad.create(charger.components); ... ``` ### Additional connections This particular IC needs a solar panel and a battery connected to it as explained in the documentation. ## Layout Build the project, open the PCB and you will find the package: components, connections, and tracks grouped together. You can drag it around your board and route tracks to it as needed. --- ## Voltage Divider *Make a Voltage Divider in **type**CAD* In this example, we will make a voltage divider. This is the equivalent circuit: ![Voltage Divider](/examples/voltage-divider/voltage-divider.png) Very simple, just two resistors. Voltage on the top, ground on the bottom, with half the voltage in the middle. ### Video ## Make a **type**CAD project From a terminal, run: ```bash typecad create ``` Call this project `voltage_divider`. No need to make a PlatformIO project or initialize a git repo unless you want to. No extra packages are needed either, but feel free to add them later if you want. Like the output said, open `voltage_divider.code-workspace` in VSCode to get started. You should see `NPM Scripts` in the sidebar with a few scripts. If you don't, click `View > Open View >` and enter `NPM Scripts`. ### Test build Click the `🤖 Build` script and you should see some build output in a terminal. If everything is [installed](/docs/requirements) correctly, you should be able to build the project without any errors. The `r1` resistor is there as test code. It, and the rest of the code, is contained in `./src/voltage-divider.ts`. ## Making resistors You can delete most of the starter code in `voltage_divider.ts` so you're left with this: ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '1kohm' }); typecad.create(r1); ``` This code creates a `PCB` object called `typecad` and a `Resistor` object called `r1`. We need two resistors, so let's make another. ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '1kohm' }); let r2 = new Resistor({ value: '1kohm' }); // [!code ++] typecad.create(r1, r2); // [!code ++] ``` Don't forget to add `r2` to the `create` method. ### `@typecad/passives` Most passives can be added in this way. For all the documentation, visit the [package](https://www.npmjs.com/package/@typecad/passives) page. Resistors, capacitors, inductors, fuses, diodes and LEDs in various sizes can be made this way. Connectors and testpoints are also in the package. ### Resistor properties Components have several properties, the one we're concerned with here is `value` (VSCode tooltips will tell you all the other properties). Our example schematic used 10kOhm resistors, so let's change that. ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); // [!code ++] let r2 = new Resistor({ value: '10kohm' }); // [!code ++] typecad.create(r1, r2); ``` ## Build Build the schematic again. Click the `open_board` script. When KiCAD opens you should see two resistors on the board. > [!TIP] > To see the changes in your code in KiCAD, use the `Revert` menu item in `File`. You may want to hotkey this function since you'll be using it a lot with typeCAD. ## Connections To create our voltage divider, we need to connect our two resistors together. ```ts import { PCB } from '@typecad/typecad' import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); typecad.net(r1.pin(2), r2.pin(1));// [!code ++] typecad.create(r1, r2); ``` If we want, we can give this connection a name so it is clearer in KiCAD. ```ts typecad.net(r1.pin(2), r2.pin(1));// [!code --] typecad.named('vdiv').net(r1.pin(2), r2.pin(1));// [!code ++] ``` ## Build again When you build again, you'll see the connection we just made inside KiCAD. ## Power We need to add a power source to make something happen. A `Power` object represents a physical source of power in **type**CAD. Don't think of it like the VCC or GND symbol in a schematic, but more like a power regulator or battery as it would be in your PCB; it has pins and is an actual component. For this simple example, the pins will be the top of `R1` and the bottom of `R2`. ```ts import { PCB, Power } from "@typecad/typecad" // [!code ++] import { Resistor } from '@typecad/passives/0603'; let typecad = new PCB('voltage_divider'); let r1 = new Resistor({ value: '10kohm' }); let r2 = new Resistor({ value: '10kohm' }); let vcc = new Power({ power: r1.pin(1), gnd: r2.pin(2), voltage: 5.0 }); // [!code ++] typecad.named('vdiv').net(r1.pin(2), r2.pin(1)); typecad.create(r1, r2); ``` There won't be anything to see after this change from with KiCAD, but the schematic will have a VCC, GND and power flags. --- ## Zones *Zones and Keepout Areas* **type**CAD supports creating filled copper zones and keepout areas on your PCB. Zones are commonly used for ground pours and power planes. ## Filled Copper Zones Create a filled copper zone (e.g., ground pour): ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('zone_example'); // Create a ground zone on the bottom copper layer pcb.zone({ net: 'GND', layers: ['B.Cu'], x: 0, y: 0, width: 50, height: 30, }); pcb.create(); ``` ### Zone Options - **net**: The net name for the zone (e.g., `GND`, `VCC`) - **layers**: Array of copper layers (`['F.Cu']`, `['B.Cu']`, or inner layers) - **x**, **y**: Position of the zone - **width**, **height**: Dimensions of the zone ## Keepout Zones Restrict routing and placement in specific areas: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('keepout_example'); // Create a keepout zone (e.g., around a sensitive analog section) pcb.keepout({ layers: ['F.Cu', 'B.Cu'], x: 20, y: 10, width: 20, height: 15, restrictions: { tracks: true, vias: true, copperpour: true }, }); pcb.create(); ``` ### Keepout Options - **layers**: Array of layers to apply the keepout to - **x**, **y**: Position of the keepout zone - **width**, **height**: Dimensions of the keepout zone - **restrictions**: Object with boolean flags: `tracks`, `vias`, `copperpour`, `pads`, `footprints` ## Graphics **type**CAD also supports drawing graphical elements on the PCB: ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('graphics_example'); // Draw a line pcb.line({ start: { x: 0, y: 0 }, end: { x: 10, y: 10 }, layer: 'F.SilkS', width: 0.15 }); // Draw a circle pcb.circle({ center: { x: 25, y: 25 }, radius: 5, layer: 'F.SilkS', width: 0.15 }); // Draw a rectangle pcb.rect({ x: 0, y: 0, width: 20, height: 15, layer: 'Edge.Cuts', strokeWidth: 0.15 }); // Draw text pcb.text({ text: 'REV 1.0', x: 5, y: 5, layer: 'F.SilkS', width: 1, height: 1 }); pcb.create(); ``` --- ## Getting Started *Getting Started with typeCAD* This guide will help you get started with **schematic-as-code**. ## What is typeCAD? typeCAD is a modern hardware design platform that brings the power of TypeScript to electronic design. It allows you to: - Create modular, reusable hardware designs - Version control your hardware designs using git - Generate production-ready outputs for manufacturing - Collaborate with other designers using familiar development tools ## Quick Start 1. **Install Node.js** - Download and install [Node.js](https://nodejs.org/) (LTS version recommended) - Verify installation by running `node --version` in your terminal 2. **Create Your First Project** ```bash npx @typecad/typecad create ``` 3. **Start Designing** - Open the project in VS Code - Begin creating your hardware design using TypeScript - Run `typecad build` to generate outputs 4. **Layout in KiCAD** - Open the `kicad_pcb` file in the `./build` folder - Your components and connections will be there - If you make changes in typeCAD, you can see them by clicking `File > Revert`. ## Next Steps - Start with making a simple [voltage divider circuit](/examples/voltage-divider) - Check out the [Documentation](/docs) for detailed guides - Join our [Reddit community](https://www.reddit.com/r/typecad/) for support and discussions --- ## Git *Git for Hardware Design* ## Why Hardware Needs Version Control Traditional hardware design tools create binary files that are impossible to meaningfully version control. typeCAD generates text-based TypeScript files that work perfectly with git, bringing modern version control to hardware design. ## Git Workflows for Hardware ### 🔍 **Meaningful Diffs** ```ts // See exactly what changed in your circuit let r1 = new Resistor({ value: "1kohm" }); // [!code --] let r1 = new Resistor({ value: "10kohm" }); // [!code ++] // Added pull-up resistor for I2C // [!code ++] let r_pullup = new Resistor({ value: "4.7kohm" }); // [!code ++] typecad.net(mcu.SDA, r_pullup.pin(1)); // [!code ++] ``` Unlike binary schematic files, git diffs show you exactly which components changed, what connections were added, and the reasoning behind each modification. ### 🌿 **Feature Branches for Circuit Development** ```bash git checkout -b feature/add-usb-connector # Develop USB connector circuit git add src/usb-connector.ts git commit -m "Add USB-C connector with ESD protection" git checkout -b feature/power-supply-redesign # Redesign power supply in parallel git add src/power-supply.ts git commit -m "Switch to buck converter for better efficiency" ``` Develop different circuit features in parallel without conflicts. Test each design independently before merging. ### 📋 **Commit Messages That Matter** ```bash git commit -m "Fix: Increase decoupling cap to 10uF for stability" git commit -m "Add: Current limiting resistor for LED protection" git commit -m "Refactor: Extract common power supply to shared module" ``` Document the electrical reasoning behind each change. Future you (and your team) will thank you when debugging. ### 🔄 **Hardware Design Reviews** ```typescript // Pull request review comments on actual circuit code let r_current = new Resistor({ value: "100ohm" }); // 👈 "This seems high for LED current limiting" typecad.net(mcu.GPIO1, led.anode); // 👈 "Missing current limiting resistor" ``` Review hardware designs like software code. Comment on specific lines, suggest improvements, and ensure design quality before merging. ## Git vs. Traditional Hardware Workflows | Traditional Hardware Tools | typeCAD + Git | | ------------------------------------- | ------------------------------------------ | | 📁 `circuit_v1.sch`, `circuit_v2.sch` | 🏷️ Semantic versioning with tags | | � Manual file backups | �P Automatic distributed backups | | ❓ "What changed?" mystery files | 📝 Clear commit history with reasoning | | � Email schematics for review | 🔍 Pull request reviews with line comments | | 🚫 No parallel development | 🌿 Feature branches for concurrent work | | 📧 "Latest version" email chains | 🎯 Single source of truth in main branch | ## Real-World Git Workflow **Scenario:** Adding a new sensor to an existing design ```bash # Start from stable main branch git checkout main git pull origin main # Create feature branch git checkout -b feature/add-temperature-sensor # Implement the sensor circuit # Edit src/sensors.ts to add DS18B20 temperature sensor git add src/sensors.ts git commit -m "Add DS18B20 temperature sensor with pull-up" # Test the design npm run build # Verify in KiCAD, run ERC checks # Push and create pull request git push origin feature/add-temperature-sensor # Create PR for team review # After review and approval git checkout main git merge feature/add-temperature-sensor git tag v1.2.0 -m "Release with temperature sensing" ``` ## Team Collaboration Benefits ### 🤝 **Distributed Development** Multiple engineers can work on different parts of the same PCB simultaneously without file conflicts. ### 📚 **Design History** Complete audit trail of every design decision with timestamps and author information. ### 🔒 **Release Management** Tag stable releases, maintain multiple product versions, and apply hotfixes to specific versions. ### 🌍 **Remote Collaboration** Share designs instantly with global teams. No more emailing large binary files. ## The Hardware Git Advantage Git transforms hardware design from a single-user, file-based workflow into a collaborative, version-controlled process: - **Traceability**: Every change is documented with author and reasoning - **Reliability**: Never lose work, always have backups - **Collaboration**: Multiple engineers working together seamlessly - **Quality**: Code review processes catch design errors early - **Speed**: Parallel development of different circuit sections Ready to bring modern version control to your hardware designs? [Get Started →](/getting-started) --- ## Ai *Hardware Design with AI* --- title: Hardware Design with AI description: Use AI to create reference designs from a datasheet date: '2025-4-8' categories: - tools - command-line - git - wiring - code-as-schematic published: true cover: https://unsplash.com/photos/XJuogr6jhv8/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8YWklMjBoYXJkd2FyZXxlbnwwfHx8fDE3NDQ1NjU1ODZ8MA&force=true&w=640 --- **typeCAD-prompt** is a specialized tool designed to integrate **typeCAD** with AI coding models, enabling users to generate detailed prompts for transforming IC reference designs into typeCAD packages. Leverage AI capabilities, such as those provided by Gemini 2.5, to help with the hardware design process. ### Key Features - **Automated Component Analysis**: The tool identifies components from schematics and cross-references datasheets to ensure accurate selection. - **Interactive Refinement**: Users can interact with the AI to confirm component details, adjust configurations, and resolve ambiguities during the design process. ### Workflow Overview 1. **Input Preparation**: Provide an IC datasheet (PDF or plaintext) and a schematic image. The tool generates a structured prompt for the AI model. 2. **Prompt Execution**: Use an AI platform like Cursor to execute the prompt. The AI analyzes the schematic, references the datasheet, and creates a typeCAD package. ### Installation and Usage Install **typeCAD-prompt** globally using the following command: ```bash npm i -g @typecad/typecad-prompt ``` Read more about using it [here](https://www.npmjs.com/package/@typecad/typecad-prompt). --- ## Command Line Suite *A suite of command-line tools* --- title: Command Line Suite description: Create schematics, wiring diagrams, and documentation, all from the terminal date: '2025-4-8' categories: - tools - command-line - git - wiring - code-as-schematic published: true cover: https://unsplash.com/photos/6EsIiLE3VCs/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8NzB8fHdvcmtiZW5jaCUyMGVsZWN0cm9uaWNzfGVufDB8fHx8MTc0NDEyNjM2OHww&force=true&w=640 --- We've just released [typecad-docgen](https://www.npmjs.com/package/@typecad/typecad-docgen) to automate the generation of KiCAD documentation from markdown files. This works nicely with the other command-line tools we've released. - [wiring](https://www.npmjs.com/package/@typecad/wiring) - Programmatically create wiring diagrams - [typecad-gitdiff](https://www.npmjs.com/package/@typecad/typecad-gitdiff) - See the differences between KiCAD PCB files Using those tools along with typeCAD means a huge portion of the workflow can be automated and also easily integrated into your CI/CD pipeline. --- ## Hardware Contract *Bridging Hardware and Firmware* --- title: Hardware Contract description: Generate a JSON manifest of connected MCU pins to bridge hardware and firmware date: '2026-5-13' categories: - typecad - firmware - code-as-schematic published: true cover: https://images.unsplash.com/photo-1558618666-fcd25c85f82e?w=640 --- When you design a board in **type**CAD, you know exactly which MCU pins are connected to what. But your firmware code doesn't — it just sees a generic board package with every pin available. The new **hardware contract** feature closes that gap. `pcb.contract()` generates a JSON manifest describing which MCU pins are wired in your circuit. Your firmware toolchain consumes this to generate a board wrapper that only exposes the pins and peripherals that actually exist on your board. ## The Problem Most firmware projects start with a board support package that exposes every pin on the MCU. But your actual board only uses a subset. Without a way to communicate the hardware layout to the firmware, you end up with: - Pin mismatches between hardware and firmware - No automated way to know which peripherals (I2C, SPI, UART) are available - Manual coordination between hardware and firmware developers ## The Solution After creating your board, call `contract()` with a pin mapping from your TypeHAL board package: ```ts import { PCB } from '@typecad/typecad'; import { pinMapping } from '@typehal/board-arduino-uno'; let pcb = new PCB('sensor_board'); // ... add components, create nets, place everything ... pcb.create(); // Generate the contract pcb.contract({ mcuSymbolPattern: 'ATmega328', pinMapping: pinMapping, outputPath: '../fw/hw-board/contract.json', }); ``` This produces a JSON file that looks like: ```json { "version": 1, "mcu": { "symbol": "MCU_Microchip_ATmega:ATmega328P-PU", "reference": "U1" }, "connectedPins": { "D13": { "boardName": "D13", "net": "led_net", "externalComponents": [ { "reference": "R1", "symbol": "Device:R", "value": "330" }, { "reference": "LED1", "symbol": "Device:LED", "value": "" } ] }, "A4": { "boardName": "A4", "net": "i2c_sda", "externalComponents": [ { "reference": "U2", "symbol": "Sensor:BME280", "value": "BME280" } ] } }, "availablePeripherals": { "i2c": true, "spi": false, "uart": false } } ``` ## How It Works 1. **Finds the MCU** — matches against the component symbol (e.g. `'ATmega328'`) or by exact reference designator 2. **Walks every net** — identifies which MCU GPIO pins are actually connected 3. **Collects external components** — for each connected pin, lists what else is on that net 4. **Checks peripheral availability** — reports whether I2C, SPI, and UART pins are all connected 5. **Writes the JSON** — outputs a clean manifest for your firmware toolchain Power, ground, clock, and reset pins are filtered out automatically — only GPIO shows up in the contract. ## Multiple MCUs If your board has more than one MCU, target a specific one by reference designator: ```ts pcb.contract({ mcuReference: 'U1', pinMapping: pinMapping, }); ``` ## Custom Peripherals By default, the contract checks for Arduino Uno peripheral pins. You can override these for other boards: ```ts pcb.contract({ mcuReference: 'U1', peripheralPins: { i2c: ['D21', 'D22'], spi: ['D23', 'D19', 'D18'], uart: ['D1', 'D3'], }, }); ``` ## What's Next This is the TypeCAD side of the bridge. The firmware toolchain (TypeHAL) reads this contract and generates a typed board wrapper so your firmware can only access pins that are actually wired. No more guessing. Update to the latest `@typecad/typecad` to start using contracts today. --- ## Introducing The Autorouter *Introducing the Auto Router* --- title: Introducing the Auto Router description: Let TypeCAD handle the tracks while you focus on the architecture date: '2026-05-10' categories: - features - routing - automation published: true cover: https://images.unsplash.com/photo-1518770660439-4636190af475?w=640 --- We are excited to announce the release of the TypeCAD Auto Router. We are referring to it as MAST, a combination of the algorithms it uses under the hood: Minimum Spanning Tree and A* Star. This new feature takes the manual labor out of PCB layout by automatically generating tracks between your connected pins. Now you can focus on your system architecture and let code handle the physical routing. It is still in early stages, but should be useful for simple boards. ### Smart Pathfinding The auto router uses a grid-based A* search algorithm to find valid paths on your board. It automatically detects obstacles like component pads and existing tracks, navigating around them to make successful connections. For complex nets with multiple points, the router constructs a Minimum Spanning Tree to ensure efficient routing without creating unnecessary loops. ### How to Use It Using the auto router is straightforward. Once you have defined your components and created a net, simply call `route()` on your PCB instance. ```ts import { PCB } from '@typecad/typecad'; import { Resistor } from '@typecad/passives/0805'; let typecad = new PCB('autoroute_example'); // Define and place components 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 }; // Create a net const signal_net = typecad.named('signal').net(r1.pin(1), r2.pin(1)); // Route it! typecad.route(signal_net); typecad.create(r1, r2); ``` ### Under the Hood The router operates by dividing the board into a fine grid and searching for paths cell by cell. If a net fails to route due to congestion, you can increase the grid resolution to give the router more freedom to find complex paths. We are looking forward to seeing the designs you build with this new capability! --- ## Irregular Outlines *Irregular board outlines* `pcb.outline()` gives you a filleted rectangle. Real boards are rarely rectangles: they have rounded corners, chamfers, mounting holes, and milled slots for enclosures. typeCAD now ships a full set of Edge.Cuts shape builders for exactly those cases. ## Polygons and circles ```ts import { PCB } from '@typecad/typecad'; let pcb = new PCB('board'); // arbitrary polygon board (e.g. a notched shield shape) pcb.outlinePolygon([ { x: 0, y: 0 }, { x: 100, y: 0 }, { x: 100, y: 80 }, { x: 50, y: 100 }, { x: 0, y: 80 }, ]); // circular board pcb.outlineCircle(50, 50, 50); ``` ## Cutouts Internal contours on Edge.Cuts are holes in KiCad, so cutouts are just nested closed shapes: ```ts // milled slot / non-circular cutout pcb.cutout([ { x: 20, y: 20 }, { x: 40, y: 20 }, { x: 40, y: 40 }, { x: 20, y: 40 }, ]); // mounting hole pcb.cutoutCircle(25, 25, 3); ``` ## Free-form paths For shapes made of mixed line and arc segments — think DXF-imported enclosures — use the `outlinePath()` builder: ```ts pcb.outlinePath(140, 88) .lineTo(156, 88) // straight edge .arcTo(166, 98, { x: 164, y: 90 }) // rounded corner (three-point arc) .lineTo(166, 104) .arcTo(158, 110, { x: 165, y: 108 }) .lineTo(146, 110) .lineTo(140, 102) // chamfer .lineTo(138, 94) .close(); // auto-closes back to the start ``` `close()` seals the builder and, if the path doesn't already end at its start point, adds the closing edge for you. ## Everything still works off the shape The board bounds and the edge-relative placement helpers (`fromLeft`, `fromRight`, `fromTop`, `fromBottom`, and friends) are computed from the outline's bounding box, so component placement keeps working unchanged for any board shape. See the [board layout docs](/docs/board_layout) for the full API. --- ## Jlcpcb Parts *JLCPCB Parts* --- title: JLCPCB Parts description: An easy way to search for basic and preferred components from JLCPCB's catalog date: '2025-7-22' categories: - tools - command-line - jlcpcb - parts published: true cover: https://unsplash.com/photos/bByhWydZLW0/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MjB8fGxpYnJhcnl8ZW58MHwwfHx8MTc1MzE5NjEyNnww&force=true&w=640 --- Intelligent fuzzy search for JLCPCB basic and preferred electrical components with CLI interface. This TypeScript-based npm package provides smart component search capabilities by automatically managing a local database of JLCPCB parts and offering natural language search with intelligent parameter matching. ### Dependencies This package uses [CDFER/jlcpcb-parts-database](https://github.com/CDFER/jlcpcb-parts-database) which provides a daily CSV download of all basic and preferred parts. That project depends on [yaqwsx/jlcparts](https://github.com/yaqwsx/jlcparts). Please consider supporting them. ## Features - 🔍 **Intelligent Fuzzy Search**: Find components using natural language descriptions - 📦 **Automatic Database Management**: Downloads and caches JLCPCB components database - ⚡ **Fast CLI Interface**: Quick command-line searches with formatted output - 🎯 **Smart Parameter Parsing**: Recognizes electrical values, packages, tolerances, and more - 📊 **Scored Results**: Get ranked results with match explanations - 🔄 **Auto-Updates**: Keeps component database fresh (24-hour cache) - 🎨 **Multiple Output Formats**: Detailed, compact, table, or JSON display options - 🔧 **Programmatic Integration**: JSON output for scripting and automation ## Installation ### Global Installation ```bash npm install -g @typecad/jlcpcb-parts ``` After global installation, you can use the `jlcpcb-search` command from anywhere: ```bash jlcpcb-search "10k resistor 0603" ``` ### Local Installation ```bash npm install @typecad/jlcpcb-parts ``` ## Quick Start ### Basic Search ```bash # Search for a 10kΩ resistor in 0603 package jlcpcb-search "10k resistor 0603" # Search for a 100µF capacitor rated for 16V jlcpcb-search "100uF capacitor 16V" # Search for buttons jlcpcb-search "SPST button" ``` [Read the full documentation here](https://www.npmjs.com/package/@typecad/jlcpcb-parts) --- ## Kicad 10 Compatibility *KiCad 10 Compatibility* --- title: KiCad 10 Compatibility description: We're verifying typeCAD works with the latest KiCad 10 release date: "2026-2-17" categories: - kicad - compatibility published: true --- KiCad 10 is currently in release candidate, and we're actively testing typeCAD to ensure full compatibility ahead of the final release. ## Current Status We're in the process of updating and verifying that typeCAD works correctly with KiCad 10. So far, the main `@typecad/typecad` package is working well with the new release. ## What's Next We'll continue testing the rest of the typeCAD ecosystem, including: - Package generation tools - CLI utilities - MCP server integration If you encounter any issues using typeCAD with KiCad 10, please report them on our [GitHub issues](https://github.com/attypecad/typecad/issues). --- ## Kicad Symbols *Search for operational amplifier symbols* --- title: KiCAD Symbol Search description: Fuzzy search for KiCad schematic symbols with CLI interface date: "2025-8-6" categories: - tools - command-line - kicad - symbol - search published: true cover: https://unsplash.com/photos/g3-tXWPGBLc/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MTB8fHN5bWJvbHN8ZW58MHwwfHx8MTc1NDQ4OTUxNHww&force=true&w=640 --- Intelligent fuzzy search for KiCad schematic symbols with CLI interface. This TypeScript-based npm package provides smart symbol search capabilities by processing local KiCad symbol files and offering natural language search with intelligent parameter matching. ## Features - 🔍 **Intelligent Fuzzy Search**: Find KiCad symbols using natural language descriptions - 📁 **Local File Processing**: Processes KiCad symbol files directly from your installation - ⚡ **Fast CLI Interface**: Quick command-line searches with formatted output - 🎯 **Smart Symbol Matching**: Recognizes library names, symbol names, and descriptions - 📊 **Scored Results**: Get ranked results with match explanations - 🔄 **Automatic Caching**: Caches processed symbols for fast subsequent searches - 🎨 **Multiple Output Formats**: Detailed, compact, table, or JSON display options - 🔧 **Programmatic Integration**: JSON output for scripting and automation - 💬 **Interactive Mode**: Prompt for search queries when none provided via command line ## Installation > **Note:** kicad-symbols is now bundled with `@typecad/typecad`. Install typecad to get the `kicad-symbols` CLI. ```bash npm install @typecad/typecad ``` After installation, you can use the `kicad-symbols` command via npx: ```bash kicad-symbols "op amp" ``` ## Quick Start ### Basic Search ```bash kicad-symbols "op amp" # Search for microcontroller symbols kicad-symbols "microcontroller" # Search for connector symbols kicad-symbols "connector" ``` ### Interactive Mode If you run the program without any search query, it will prompt you to enter one interactively: ```bash # Start the program without arguments kicad-symbols # The program will display: # kicad-symbols - KiCad Symbols Search Tool # No search query provided. Please enter a search term: # Examples: "capacitor", "LM358", "4xxx:14528", "op amp" # Press Ctrl+C to exit # # Search query: ``` ## Integrate in your typeCAD project Open your project's `package.json` and add the following line to the `scripts` section: ``` "KiCAD Symbol Search 🔍": "kicad-symbols" ``` --- ## Kicad Typecad Sync *Code and KiCAD* --- title: Syncing KiCAD and typeCAD description: Getting KiCAD and typeCAD to play nice together date: '2025-6-5' categories: - typecad - kicad - editing - sync - code-as-schematic published: true cover: https://unsplash.com/photos/-_yJPCofxYQ/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8NzZ8fGZyaWVuZHMlMjBwZXRzfGVufDB8MHx8fDE3NDkxNTM3NjF8MA&force=true&w=640 --- **type**CAD is meant to work closely with KiCAD, essentially replacing the schematic editor. But **type**CAD can do a lot more than the schematic editor so the best way to go about things was getting a bit hazy. ## The Problem The vast majority of PCB design and layout can be done with **type**CAD now. But there are still some things that KiCAD is better at and the best way to sync changes between moving parts in the editor versus what's generated by code wasn't clear. ## The Solution Nearly everything can have its state saved and **type**CAD is smart enough to figure out what needs to be updated and what should be left as you manually edited it. ## Some Improvements ### Saving over KiCAD changes **type**CAD used to check for a lock file to see if the PCB file was open in KiCAD. It worked, but it wasn't great. Now, it does some fancy window title checking, finds the open KiCAD window and checks for unsaved changes. The build process will stop and let you know and let you save (or not) before proceeding. If you're on a system that doesn't support this (Mac?), it will just check for the lock file. ### Tracks Tracks can have their widths changed in KiCAD, but not deleted. **type**CAD will recreate deleted tracks, so if you want to modify a track, if it it created in code, it needs to be deleted in code (delete the line). Preserved track changes are displayed during the build process, so you are made aware of any deviations from what the code as supposed to make. ### Components Components can be moved and rotated in KiCAD. **type**CAD will preserve those changes. Nearly anything you can do with components in KiCAD will be preserved. ### Vias Vias can be created in **type**CAD, so if you make any in KiCAD, the build process will let you know about them and give the coordinates so you can add them to your code. ## The End Result The goal is to have a smooth workflow between KiCAD and **type**CAD. You should be able to make changes in either if you choose, while nudging in the direction of **type**CAD for declaratively creating a PCB. --- ## Layout Improvements *Major improvements in typeCAD PCB layout* --- title: Layout Improvements description: Major improvements in typeCAD PCB layout date: '2025-4-19' categories: - layout - pcb published: true cover: https://unsplash.com/photos/T_l246EK19I/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8bGV2ZWwlMjB1cHxlbnwwfHx8fDE3NDUxMjUzMTl8MA&force=true&w=640 --- Version 0.1.2 of [typeCAD](https://www.npmjs.com/package/@typecad/typecad) was just released with major layout improvements. Before there were significant limitations on what was possible with it. Before, when a layout was applied, it moved all the components to whatever location specified in the typeCAD code. This worked well enough as an MVP, but wasn't a great developer experience. Now with this new release, that has been fixed. To keep the components from moving around, they just need to be given a UUID: ```ts this.C1 = new Capacitor({ value: '10uF', uuid: '6d588378-32ea-4e85-a943-d9b373a3d454' }); ``` There are several VS Code extensions that can help with the generation. [Here's one](https://marketplace.visualstudio.com/items?itemName=netcorext.uuid-generator). ## Other improvements There were also improvements in BOM generation. Fields can be customized in typeCAD code. --- ## Llms Txt *The llms.txt standard* --- title: typeCAD has an /llms.txt file description: Use AI to create reference designs from a datasheet date: '2025-7-6' categories: - tools - llm - ai published: true cover: https://unsplash.com/photos/OPpCbAAKWv8/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MjJ8fGNoYWxrYm9hcmQlMjB3aXRoJTIwYSUyMGxvdCUyMG9mJTIwdGV4dHxlbnwwfDB8fHwxNzUxODI0NzE5fDA&force=true&w=640 --- The standard is defined at at their website: [llms-txt](https://llmstxt.org/). Basically, it is a way to document projects for easy use with AI. ## Example use Most any LLM model allows file usage; download [`/llms-full.txt`](/llms-full.txt), provide it to your LLM, then ask it anything about **type**CAD. It should have the entire website and API available as a source of information. Embed [`/llms-full.txt`](/llms-full.txt) into a vector database and create your own agents. [Langflow](https://www.langflow.org/) or [Flowise](https://flowiseai.com/) work well for this. A scraper could also be used to download all the markdown files for more specific or fine-tuned approaches. --- ## Mcp *typeCAD MCP Server* --- title: typeCAD MCP Server description: Install our MCP server for a much smoother AI experience date: "2025-7-17" categories: - tools - command-line - git - ai - llm - mcp published: true cover: https://unsplash.com/photos/M5tzZtFCOfs/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8bmV0d29yayUyMHNlcnZlcnxlbnwwfDB8fHwxNzUyNzYxNDM1fDA&force=true&w=640 --- An MCP (Model Context Protocol) server that provides AI assistants with direct access to typeCAD tools and workflows. This enables seamless integration between AI coding assistants and typeCAD's electronic design automation capabilities. ## What is MCP? MCP (Model Context Protocol) is a standard that allows AI assistants to connect to external tools and data sources. This server exposes typeCAD's functionality as MCP tools, letting AI assistants create projects, add components, validate designs, and more. ## Features The server provides these typeCAD tools to AI assistants: - **🏗️ Create Project** - Initialize new typeCAD projects with optional PlatformIO support - **🧩 Add Component** - Add components from KiCAD libraries or JLCPCB catalog - **📄 PDF to Text** - Convert component datasheets from PDF to text format - **📚 Download Docs** - Fetch the latest typeCAD documentation - **✅ Validate Component** - Verify component definitions against datasheets - **📦 Create Package** - Generate complete IC packages from datasheets and schematics > [!tip] > `PDF to Text` is a very naive conversion tool. A far more robust tool can be found at [Datalab](https://www.datalab.to/playground). Their site provides a free option and it can also be installed locally for free. LLMs can't read PDFs, but they can read text. The better the conversion, the better the LLM can understand the datasheet and extract the relevant information. ### Passive Components Quick access to common passive components using the @typecad/passives package: - **💈 Add Resistor** - Create resistors with value, wattage, voltage rating options - **🪫 Add Capacitor** - Create capacitors with value, voltage rating options - **💡 Add LED** - Create LEDs with voltage and brightness specifications - **🔌 Add Diode** - Create diodes with voltage and efficiency specifications - **🌀 Add Inductor** - Create inductors with inductance value specifications - **🔒 Add Fuse** - Create fuses with current and voltage ratings - **🔗 Add Connector** - Create connectors with pin count and footprint options - **🎯 Add Testpoint** - Create testpoints with custom footprint options ### Power Management Tools for defining and managing power in your designs: - **🔋 Add Power Source** - Define power sources like batteries and regulators with voltage specs - **⚡ Add Power Input** - Define power input requirements for components and modules ### PCB Layout & Routing Advanced PCB design tools for layout and routing: - **🔗 Add Via** - Create vias for layer transitions with size, drill, and power specifications - **🛤️ Add Track** - Create PCB tracks with power-aware routing and layer management ### Connections & Networking Tools for managing electrical connections between components: - **🏷️ Create Named Net** - Create named connections between pins for better organization - **🔌 Connect Pins** - Connect multiple pins together in electrical networks ### Component Management Advanced component creation and modification tools: - **🧩 Create Custom Component** - Create custom components with named pins and power specs - **⚙️ Set Component Properties** - Modify component properties like DNP, reference, value, etc. ### Design Validation Comprehensive design checking and validation tools: - **✅ Validate Design** - Run comprehensive design validation including power and ERC checks - **🔍 Run ERC** - Run Electrical Rules Check to validate pin connections and compatibility ## Installation Install globally via npm: ```bash npm install -g @typecad/typecad-mcp ``` ## Configuration Add this to your MCP configuration file: ``` { "mcpServers": { "typecad-mcp": { "command": "npx", "args": ["-y", "@typecad/typecad-mcp" ], "env": {} } } } ``` ## Usage Once configured, AI assistants can use typeCAD tools directly in conversation: - "Create a new typeCAD project called 'sensor-board'" - "Add the ESP32-S3 microcontroller to my project" - "Validate this component against its datasheet" - "Create a package for this voltage regulator IC" - "Add a resistor/capacitor/inductor/diode/LED/fuse/testpoint/connector" - "Add a power source" The AI assistant will automatically call the appropriate MCP tools and guide you through any required inputs. --- ## Multilayer Boards *Boards grew a third dimension* --- title: Multilayer boards, planes, and everything copper description: N-layer stackups, planes, impedance control, polygon zones, via stitching, teardrops, and fonts date: '2026-9-4' categories: - tools - pcb - board - layers - routing - zones published: true --- This release makes the copper layer count a first-class citizen of a typeCAD board, and fills in the copper features around it: planes, controlled impedance, polygon zones, via stitching, teardrops, per-text fonts, and a zone-aware `typecad import`. ## The layer set is the source of truth ```ts let pcb = new PCB('board', { layers: 4 }); pcb.copperLayers; // ['F.Cu', 'In1.Cu', 'In2.Cu', 'B.Cu'] ``` One number drives everything: routing defaults (the autorouter uses every declared copper layer), through-hole pad clearance (pads exist on every layer they should), via spans, and write-time validation — referencing a layer that isn't declared fails with an actionable error instead of producing a board KiCad can't open. Physical construction comes from `pcb.stackup()`, now with per-layer material overrides (`thickness`, `material`, `epsilon_r`, `loss_tangent`) that redistribute the remaining dielectric budget to keep the board at its total thickness. ## Planes ```ts pcb.outline(0, 0, 60, 45); pcb.plane('GND', 'In1.Cu'); pcb.plane('+3V3', 'In2.Cu'); ``` A plane dedicates a whole layer to a net: at `create()` it becomes a board-covering filled zone (through-hole pads connect solid, SMDs reach it through vias), and the autorouter keeps signals off the layer. Net classes can claim preferred layers (`pcb.netClass('mem', { layers: ['In2.Cu'] })`) — through-hole nets anchor directly on the class's layer. ## Controlled impedance, now with tolerance ```ts pcb.impedanceWidth('In1.Cu', 50); // exact solved width pcb.impedanceWidth('F.Cu', 50, 5); // snapped to a 0.01mm fab grid within 50±5Ω pcb.route(clk, { impedance: { target: 100, tolerance: 10 } }); ``` Microstrip on outer layers, symmetric stripline on inner ones, computed from the board's resolved stackup. With a tolerance, the width snaps to a fabrication grid inside the band; if the design-rule floor forces the trace outside it, routing warns with the achieved impedance. ## Via policy ```ts pcb.viaPolicy({ type: 'through' }); // default: budget-fab-friendly pcb.viaPolicy({ type: 'blind-buried', maxSpan: 2 }); // exact layer pairs, span-limited ``` Router vias follow a manufacturing policy instead of silently emitting buried vias for inner-layer transitions. ## Zones grew up ```ts pcb.zone({ net: 'GND', layers: ['F.Cu'], points: [{ x: 10, y: 10 }, { x: 20, y: 10 }, { x: 20, y: 14 }, { x: 14, y: 14 }, { x: 14, y: 20 }, { x: 10, y: 20 }], fill: { mode: 'hatched', hatchWidth: 0.2, islandRemovalMode: 2 }, }); ``` Arbitrary polygons (`points`), grouped fill settings mirroring KiCad's `(fill ...)` block, `filledAreasThickness` finally serialized, `islandRemovalMode` actually defaulting to 2, and rule areas with `placement`. Unconnected pours (no net) are legal. Keepouts take the same geometry. ## Via stitching ```ts pcb.stitch('GND', { pitch: 1.5 }); // → number of vias placed ``` A clearance-aware grid of vias tying pours to planes. Candidates are skipped against pads, tracks, vias, zones, and keepouts on every layer the stitch spans — component footprints block regardless of net (even components that aren't placed yet), same-net pours never block, and a partial `layers` span emits blind vias over exactly that span. ## Teardrops ```ts pcb.teardrops(); // writes KiCad's tool settings AND generates wedge geometry at router vias ``` Reinforced track-to-via junctions: the `.kicad_pro` opens preconfigured, and vias placed by the autorouter get real tapered wedge segments on each layer they connect. ## Fonts and arcs ```ts r1.referenceLayout = { x: 0, y: -1.5, font: 'OCR A Std', bold: true }; pcb.arc({ start: { x: 10, y: 10 }, mid: { x: 13.5, y: 13.5 }, end: { x: 15, y: 10 }, layer: 'F.SilkS' }); ``` TrueType faces on component text and `pcb.text()` (via KiCad's `(face ...)`), with `bold`/`italic` now actually emitted, plus three-point arcs completing the graphics set. ## `typecad import` keeps zones Imported boards no longer silently lose their copper: pours emit as `pcb.zone()` with polygon geometry and fill settings, rule areas as `pcb.keepout()` with their restrictions, and stackups as `pcb.stackup(N)`. ## Verified against the parser Every serializer token introduced here — `(face ...)`, `(mode hatch)`, `(filled_areas_thickness ...)`, `(placement ...)`, the `.kicad_pro` teardrop arrays — was probed against KiCad 10's parser before shipping, and the full demo board (planes, stitching, teardrops, hatched pours) loads cleanly. A few tokens that didn't survive verification (`custom_rule`, zone-level `smoothing`, `(mode hatched)`) were removed or fixed along the way. --- ## New Site *cover: https://unsplash.com/photos/b0p818k8Ok8/download?ixid=M3wxMjA3fDB8MXxjb2xsZWN0aW9ufDh8MjU1MTgzMXx8fHx8Mnx8MTcyNTU0MDM2N3w&force=true&w=640* --- title: New Site description: Welcome to our new site date: '2025-3-10' categories: - website published: true --- # New Site We switched to a new site, so watch here for updates on **type**CAD. --- ## Package Auto Sync *Packages without install scripts* npm is deprecating `postinstall` and other install scripts for security reasons, and typeCAD packages historically relied on exactly that: a generated `postinstall.js` that copied each package's bundled KiCad symbol and footprint files from `node_modules` into the project's `./build/` directory at install time. That script is gone. The same copy now happens at **build time**, inside typeCAD itself — with no install scripts, no special npm flags, and no user interaction. ## How it works When a component package that bundles a `./build/lib/` directory is used, typeCAD resolves the package's own source directory and syncs its contents into the project's `./build/lib/` the first time the `Package` is constructed during a build: ```bash package/build/lib/ ├── ISL9120IRTNZ.kicad_sym → ./build/lib/ISL9120IRTNZ.kicad_sym ├── footprints/ │ └── QFN50P300X300X75-13N-D.kicad_mod → ./build/lib/footprints/QFN50P300X300X75-13N-D.kicad_mod ``` The sync runs on every build but is mtime-guarded — files that are already up to date are skipped, so repeat builds only pay for a few `stat` calls. Because the package's location is resolved from the running code itself, it works with any package name, any registry layout (npm, yarn, pnpm), `file:` dependencies, and monorepo links. ## For package authors - If your package's class **extends `Package`**: nothing to do. The base-class constructor handles the sync automatically. - If your package uses a **hand-rolled class**, call the exported helper once in your constructor: ```ts import { syncThisPackageBuildLib } from '@typecad/typecad'; export class MyModule { constructor(options) { syncThisPackageBuildLib(); // ... } } ``` `typecad add package` scaffolds new packages with the `Package` base class and no install scripts. ## For package consumers Nothing changes. `npm install` your packages as usual — zero lifecycle scripts run — and build. The files appear in `./build/lib/` exactly where KiCad expects them (`fp-lib-table` and the runtime loaders already point there). --- ## Power Aware *Building power aware circuits with typeCAD* --- title: Power aware design description: typeCAD can check for power compatibility between components now date: '2025-6-12' categories: - typecad - kicad - editing - sync - code-as-schematic published: true cover: https://unsplash.com/photos/SG9Ycz2uqGs/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8NDR8fGRvJTIwbm90JTIwdG91Y2h8ZW58MHwwfHx8MTc0OTc0NTg2M3ww&force=true&w=640 --- **type**CAD can now check for power issues as you develop your circuits. ## Current carrying tracks When creating tracks, you can pass a `powerInfo` object that includes the current the track will carry. **type**CAD will check that the track is wide enough to handle the current. ```ts let 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}) .to({x: 110, y: 120, layer: "B.Cu"}) ``` Using the above code, **type**CAD will check that the track is wide enough to handle 1 amp of current for the specified temperature rise and copper thickness. If not, it will throw an error during build. Like this: ``` [TrackBuilder] ERROR: Track width 0.2mm is too narrow for 1A current on F.Cu. Minimum width should be 0.300mm. ``` This works for any segment of track and it is automatically done during every build. You don't need to have a separate calculator and manually check each track segment. ## Current carrying vias Vias can be created with the optional `powerInfo` object. This allows **type**CAD to check that the current draw through the via is within the limits of the via's rating using the IPC-2221 standard. `maxTempRise` is the maximum wanted rise in temperature of the via, default is 10 C. `thickness` is the thickness of the via's copper in microns. 35 is the default (1 oz). ```ts let via = pcb.via({ at: { x: 10, y: 10 }, size: 0.6, drill: 0.3, powerInfo: { current: 3, maxTempRise: 10, thickness: 35 }, }); ``` Using the above code, **type**CAD will check that the via is large enough to handle 1 amp of current for the specified temperature rise and copper thickness. If not, it will throw an error during build. Like this: ``` [PCB VIA] ERROR: Via size 0.6mm (drill 0.3mm) is too small for 3A current. Maximum capacity is 2.75A @ 10°C rise ``` This also works automatically during every build. ## Connecting power aware tracks, vias and pins **type**CAD also now allows for `powerInfo` objects to be attached to pins of components. This allows for checking proper voltage levels and current draw between components and the nets they are connected to. - If you try to connect a device that draws 1 Amp, but only power it with a 0.8 Amp power supply, you'll see an error. - If you try to connect a 5V device to a 3.3V power supply, you'll see an error. - and many more issues are detected This all happens automatically during every build. ## Taking advantage of programmatic circuit design This is a good example of taking full advantage of programming concepts for circuit design. --- ## Private Npm Packages *Keeping your work private* --- title: Private npm Packages description: Host your own npm packages date: '2025-3-17' categories: - website published: true cover: https://unsplash.com/photos/f3Ug9b50KwI/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzQyMjQzNzYxfA&force=true&w=640 --- [npm](https://www.npmjs.com/) is a great way to share your work with the world, but sometimes you may want to keep your work private or have more control over it. In those case, you can use [npm private packages](https://docs.npmjs.com/about-private-packages). You have to pay $7 per month per user. You can create private packages and publish them to your own private registry. ## Private Registry Maybe you have a server that you can use. If so, you can use [verdaccio](https://verdaccio.org/) to create your own private registry. It's just a single command to install and run. And using it is equally simple, just add a `--registry [server address]` to your `npm install` or `npm publish` command. --- ## Schematics *Make a schematic file in typeCAD* --- title: Schematics description: Generate a schematic file from typeCAD projects date: '2025-5-13' categories: - tools - command-line - schematic - code-as-schematic published: true cover: https://unsplash.com/photos/QCOg4dicY74/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8N3x8ZWxlY3RyaWNhbCUyMHNjaGVtYXRpY3xlbnwwfHx8fDE3NDcxNDE4OTB8MA&force=true&w=640 --- A schematic file isn't needed since typeCAD code takes the place of it, but it can be useful to have one available. People will likely still want to look at a schematic rather than code. Schematic generation is now built into `PCB.create()` — calling `create()` produces a `.kicad_pcb`, `.kicad_sch`, and `.net` file automatically. ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('my-board'); typecad.create(r1, c1, led); // Generates: ./build/my-board.kicad_pcb, ./build/my-board.kicad_sch, ./build/my-board.net ``` No separate import or function call is needed. --- ## Simplification *Simplification* --- title: typeCAD Simplification description: The entire typeCAD API has been simplified and interaction between KiCAD and typeCAD has been improved. date: '2025-5-30' categories: - tools - command-line - git - wiring - code-as-schematic published: true cover: https://unsplash.com/photos/_SEbdtH4ZLM/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MjN8fGVhc2llcnxlbnwwfDB8fHwxNzQ4NjY4MzA0fDA&force=true&w=640 --- **type**CAD was growing in features at the expense of simplicity. The entire API has been simplified and the interaction between KiCAD and typeCAD has been improved while also maintaining backwards compatibility. ## `Schematic` and `PCB` The `Schematic` and `PCB` classes have been merged into a single `PCB` class. The `PCB` class now has a `schematic` property that contains the schematic data. The `PCB` class also has a `create` method that takes a list of components and adds them to the schematic and board. This change was made because the schematic and board are always created together and there was no need to have two separate classes. Also, **type**CAD was the schematic, so why put any mental effort into another 'Schematic'? Now the bare minimum code to create a board is: ```ts import { PCB } from '@typecad/typecad'; let typecad = new PCB('typecad'); typecad.create(); ``` There's no need to think about `Schematic` anymore. All the functionality is still there, but it's stubbed out in the `PCB` class. `::net` and `::named` are called from `PCB` now. So is `::bom` and `::erc`. ## KiCAD The interaction between **type**CAD and KiCAD was getting unintuitive. Wondering if you needed to Revert to see component location changes or reimport the netlist to see other updates was confusing. Now, **type**CAD will automatically import the netlist after running `PCB::create()`. That means you never have to interact with the netlist file again. Any changes made to the board will be reflected in their entirety when you run `PCB::create()` and use the Revert function (or just reopen) the board in KiCAD. ### More KiCAD integration to come Soon, we'll be releasing a new version that will check for a dirty .kicad_pcb file and prompt you to revert before running `PCB::create()`. This will prevent any changes you've made in KiCAD from being lost. It will be more robust and useful that the current method which just checks for the existence of a lock file. ## Package improvement We've tweaked things to make packages easier to create and use. They are now created similarly to other components, and also used the same as well. Before, our example packages had `add` and `place` methods. Now, they have a property that holds everything in a `components` array. The result is a much simpler and more intuitive package creation and use. ## `npm update` Update your projects and packages to the latest version to get the latest features and improvements. --- ## Tracks *Create tracks with typeCAD* --- title: Route your boards description: Use AI to create reference designs from a datasheet date: '2025-5-25' categories: - tools - routing - tracks - board - pcb - code-as-schematic published: true cover: https://unsplash.com/photos/FwzhysPCQZc/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8MzF8fHdpcmVzfGVufDB8MHx8fDE3NDgxODk5OTh8MA&force=true&w=640 --- One of the last parts of board design was routing and that is largely accomplished now with the newest release. ## `TrackBuilder` The `TrackBuilder` object lets you create tracks with a fluent API. ```ts import { PCB, TrackBuilder } from '@typecad/typecad'; let pcb = new PCB('typecad_docs'); let power_track: TrackBuilder = this.pcb.track() .from({x: 100, y: 100}, "F.Cu", 0.2) // Start on F.Cu, 0.2mm wide (these are the defaults and can be omitted) .to({x: 110, y: 100}) // go to 110, 100 .via({size: 0.8, drill: 0.4}) // create a via at the 110, 100 .to({x: 110, y: 120, layer: "B.Cu"}); // Continues on B.Cu pcb.group('typecad_docs', power_track); // add the TrackBuilder to the group pcb.create(); ``` This method fits in nicely with the rest of the **type**CAD API. ### Connections `TrackBuilder` objects don't take any connection information. This is because KiCAD will connect any track that touches an element with a net, ie. a track that touches a pad connected to the 'gnd' net will make the entire track also connected to the 'gnd' net. Since there's no use for an unconnected track, this simplifies to process. ## kicad2typecad `kicad2typecad` (bundled with [@typecad/typecad](https://www.npmjs.com/package/@typecad/typecad)) is a tool to simplify making tracks. This is particularly useful for making packages. You can lay out the entire package in KiCAD; components placed, tracks drawn, and vias added. Then use `kicad2typecad` to generate the code snippets to create them programmatically in the package. ### Making a package The workflow for creating a reusable package is: 1. Create a package, add components and connections 2. Layout the board in KiCAD using tracks and vias 3. Use `kicad2typecad` to generate the code snippets 4. Add the code snippets to the package An example output for a small package looks like this: ```bash Reading from File: .\typecad_docs.kicad_pcb Found 6 segments. Generating TrackBuilder chains from File: .\Reading from File: .\typecad_docs.kicad_pcb. --- Generated typeCAD TrackBuilder Code from File: .\typecad_docs.kicad_pcb --- this.pcb.track().from({ x: 152.05, y: 96.87 }, "F.Cu", 0.2) .to({ x: 152.4, y: 96.52, layer: "F.Cu", width: 0.2 }); this.pcb.track().from({ x: 151.1, y: 99.665 }, "F.Cu", 0.2) .to({ x: 151.765, y: 100.33, layer: "F.Cu", width: 0.2 }) .to({ x: 152.273, y: 99.822, layer: "F.Cu", width: 0.2 }) .to({ x: 153.67, y: 99.822, layer: "F.Cu", width: 0.2 }); this.pcb.track().from({ x: 150.6, y: 99.175 }, "F.Cu", 0.2) .to({ x: 151.1, y: 99.175, layer: "F.Cu", width: 0.2 }) .to({ x: 151.1, y: 99.665, layer: "F.Cu", width: 0.2 }); --------------------------------------------------------- Found 4 footprints. Generating placement code from File: .\typecad_docs.kicad_pcb. --- Generated Component Placement Code from File: .\typecad_docs.kicad_pcb --- this.C1.pcb = { x: 153.67, y: 99.047, rotation: -90 }; this.C2.pcb = { x: 153.67, y: 95.986, rotation: -90 }; this.VR1.pcb = { x: 150.6, y: 97.725, rotation: 0 }; this.L1.pcb = { x: 147.32, y: 97.828, rotation: 90 }; ------------------------------------------------------------- Found 3 vias. Generating typeCAD code from File: .\typecad_docs.kicad_pcb. --- Generated typeCAD Via Code from File: .\typecad_docs.kicad_pcb --- this.v1 = this.pcb.via({ at: { x: 110, y: 100 }, size: 0.8, drill: 0.4 }); this.v2 = this.pcb.via({ at: { x: 152.4, y: 96.52 }, size: 0.6, drill: 0.3 }); this.v3 = this.pcb.via({ at: { x: 151.765, y: 100.33 }, size: 0.6, drill: 0.3 }); ----------------------------------------------------- ``` ### Using the code The `TrackBuilder` objects can be used within a package directly. That's why they are prefixed with `this`. One modification would be to place the return value of each `this.pcb.track` into a `TrackBuilder` object which can then be used to place in a package group. The vias can also be used directly, or you can just take their location data. For `Component` objects, the package doesn't read your code so it doesn't know what the variable names for your components are. It just uses the reference to show the code snippet. --- ## V0.3 Release *typeCAD 0.3* --- title: typeCAD 0.3 Release description: Breaking changes, unified CLI, text positioning, and simplified API date: '2026-6-1' categories: - release - typecad - cli - breaking-change published: true cover: https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=640 --- Version 0.3 is a breaking change release that consolidates the typeCAD ecosystem into a single package and introduces a unified command-line tool. ## One package, one install `@typecad/typecad-docgen` and `@typecad/typecad-gitdiff` have been merged into the main `@typecad/typecad` package. What previously required three separate installs now takes one: ```bash npm install @typecad/typecad ``` Both tools remain available programmatically via subpath exports: ```ts import { generateDocumentation } from '@typecad/typecad/docgen'; import { generateDiffs } from '@typecad/typecad/diff'; ``` ## The `typecad` binary A new unified CLI replaces the previous collection of separate commands. Running `npx typecad` or the installed `typecad` binary gives access to: | Command | Description | |---------|-------------| | `typecad create` | Create a new typeCAD project | | `typecad add component` | Add a component to the current project | | `typecad add package` | Create a reusable component package | | `typecad build` | Build KiCad output from typeCAD source | | `typecad search` | Search KiCad schematic symbols | | `typecad import` | Convert a KiCad PCB file to typeCAD code | | `typecad diff` | Compare two KiCad PCB files visually | | `typecad doc` | Generate PCB documentation from Markdown | | `typecad doctor` | Check your environment for common issues | | `typecad validate` | Validate project source without a full build | | `typecad drc` | Run Design Rule Check on a KiCad PCB file | | `typecad erc` | Run Electrical Rules Check on a KiCad schematic | The `diff` and `doc` commands are the same tools that were previously separate packages, now accessible without an additional install. ## Text, value, silkscreen, and fab positioning Components now accept layout properties that control where and how text appears on the board. Three layout properties are available: - **`referenceLayout`** -- Controls the reference designator text position (defaults to F.SilkS) - **`valueLayout`** -- Controls the value text position (defaults to F.Fab) - **`fabLayout`** -- Controls fabrication layer text (defaults to F.Fab) Each accepts position, rotation, layer, font size, thickness, and justification: ```ts let r1 = new Component({ footprint: 'Resistor_SMD:R_0603_1608Metric', reference: 'R1', referenceLayout: { x: 0, y: -1.5, rotation: 90, width: 0.8, height: 0.8 }, valueLayout: { x: 0, y: 1.5, width: 0.6, height: 0.6 }, fabLayout: { x: 0, y: 0, text: 'R1' }, }); ``` Arbitrary text entries can also be added to any component via the `text` property, which accepts an array of positioned and styled text objects. ## Simplified component API The `Component` constructor now accepts a single `ComponentInit` object with all properties optional. The previous `IComponent` type is deprecated. Components can be created with minimal configuration: ```ts let R1 = new Component({ value: '1kohm' }); ``` The `Package` base class was also rewritten. Components assigned to `this` inside a `build()` method are collected automatically, so there is no need to push them into an array manually. Helper methods for `net()`, `via()`, `track()`, and `add()` are provided on the base class. ## Breaking changes - `@typecad/typecad-docgen` and `@typecad/typecad-gitdiff` are no longer published separately. Use the `typecad doc` and `typecad diff` commands, or import from `@typecad/typecad/docgen` and `@typecad/typecad/diff`. - The `IComponent` type alias is deprecated in favor of `ComponentInit`. - The CLI entry points from previous separate packages have been replaced by the `typecad` binary. --- ## Package *npm Packages for Hardware* ## Why Hardware Needs a Package Manager Traditional hardware design forces you to rebuild the same circuits over and over. typeCAD brings the npm ecosystem to hardware design, letting you install, share, and reuse proven circuit designs as packages. ## The npm Ecosystem for Hardware ### 📦 **Install Hardware Like Software** ```bash # Install common passive components npm install @typecad/passives # Add specialized sensor packages npm install @mycompany/environmental-sensors npm install @community/power-supplies # Install development tools npm install --save-dev @typecad/jlcpcb-export ``` No more hunting through component libraries or rebuilding basic circuits. Install proven designs with a single command. ### 🔌 **Import Circuits Like Modules** ```typescript // Import exactly what you need import { Resistor, Capacitor, LED } from '@typecad/passives/0603'; import { UsbCConnector } from '@acme/connectors'; import { BuckConverter5V } from '@acme/power-supplies'; // Use them immediately let power = new BuckConverter5V({ inputRange: [7, 24] }); let usb = new UsbCConnector({ dataLines: true }); let led = new LED({ color: 'blue', current: 20 }); ``` Import hardware components with the same simplicity as importing software libraries. TypeScript intellisense shows you all available options. ### 🏗️ **Build Complex Systems from Simple Parts** ```typescript // Combine packages to build complete systems import { ESP32DevKit } from '@typecad/microcontrollers'; import { SensorCluster } from '@mycompany/environmental'; import { LoRaModule } from '@community/wireless'; let mcu = new ESP32DevKit(); let sensors = new SensorCluster(['temperature', 'humidity', 'pressure']); let wireless = new LoRaModule({ frequency: 915 }); // Connect them together typecad.net(mcu.I2C_SDA, sensors.SDA); typecad.net(mcu.I2C_SCL, sensors.SCL); typecad.net(mcu.SPI_MOSI, wireless.MOSI); ``` Compose complex IoT devices from well-tested, modular packages. Each package handles its own complexity internally. ### 📋 **Dependency Management That Works** ```json // package.json for your hardware project { "name": "weather-station-v2", "version": "1.2.0", "dependencies": { "@typecad/typecad": "^2.1.0", "@typecad/passives": "^1.5.0", "@acme/sensors": "^3.2.1", "@community/displays": "^2.0.0" }, "devDependencies": { "@typecad/validation": "^1.1.0" } } ``` Lock dependency versions for reproducible builds. Update packages when new features or bug fixes are available. ## npm vs. Traditional Hardware Workflows | Traditional Hardware Design | typeCAD + npm | |---------------------------|---------------| | 🔄 Rebuild same circuits repeatedly | 📦 `npm install @company/power-supply` | | 📁 Copy-paste component groups | 🔌 `import { UsbConnector } from '@lib/usb'` | | 🔍 Hunt through component libraries | 🔎 `npm search temperature-sensor` | | ❓ Unknown component reliability | ⭐ Package ratings and download stats | | 📧 Email circuit files around | 🌐 `npm publish` for instant sharing | | 🐛 No update notifications | 🔔 `npm outdated` shows available updates | ## Publishing Your Own Packages ### 🚀 **Share Your Designs** ```bash # Create a reusable sensor breakout package mkdir my-sensor-package cd my-sensor-package npm init @typecad/package # Develop your sensor circuit # Edit src/index.ts # Publish to npm npm publish ``` Turn your proven designs into packages that others can use. Build a reputation for reliable hardware designs. ### 🏢 **Private Company Packages** ```bash # Keep proprietary designs private npm publish --registry=https://npm.company.com # Team members install from private registry npm install @company/secret-sauce-v2 ``` Share designs within your organization while keeping IP protected. Use npm's private registry features. ## The Package Ecosystem Advantage npm transforms hardware design from isolated, repetitive work into a collaborative ecosystem: - **Reusability**: Never rebuild the same circuit twice - **Quality**: Use tested designs from the community - **Speed**: Compose complex systems from proven modules - **Collaboration**: Share and improve designs across teams - **Innovation**: Focus on unique value, not reinventing basics - **Maintenance**: Get updates and bug fixes automatically Ready to tap into the world's largest package ecosystem for your hardware designs? [Get Started →](/getting-started) --- ## Packages *Packages* ## Reference Designs | | | | :-----------------------------------------------------------------: | ----------------------------------------------------------------------------------------------------------------------------------- | | [rd-ESP32S3](https://www.npmjs.com/package/@typecad/rd_esp32s3) | reference design for the ESP32-S3-MINI-1-N8. A module that provides 2.4 GHz b/g/n WiFi and BLE 5 connectivity, MCU, and PCB antenna | | [rd-ISL9120IR](https://www.npmjs.com/package/@typecad/rd_isl9120ir) | reference design for the ISL9120IR. A Compact High Efficiency Low Power Buck-Boost Regulator | | [rd-bq24210](https://www.npmjs.com/package/@typecad/rd-bq24210) | reference design for the bq24210 800-mA, Single-Input, Single-Cell Li-Ion Battery Solar Charger | ## Utility packages | | | | :-----------------------------------------------------------------------: | --------------------------------------------------------------------------------------------------- | | [graphviz](https://www.npmjs.com/package/@typecad/graphviz) | view connections in your typeCAD project | | [wiring](https://www.npmjs.com/package/@typecad/wiring) | Programmatically Create Wiring Diagrams | | [jlcpcb-export](https://www.npmjs.com/package/@typecad/jlcpcb-export) | export all the required files for JLCPCB assembly from a typeCAD project | | [jlcpcb-parts](https://www.npmjs.com/package/@typecad/jlcpcb-parts) | Fuzzy search for JLCPCB basic and preferred electrical components | --- ## API Reference --- ## passives *typeCAD Passives* This is a typeCAD package that includes simple access to many passive components. ## Package Import Reference | Component Type | Package | Import Example | |----------------|---------|----------------| | Resistors, Capacitors, LEDs, Diodes | `@typecad/passives/0603` | `import { Resistor, Capacitor } from '@typecad/passives/0603'` | | Same components, different sizes | `@typecad/passives/0805` | `import { Resistor, Capacitor } from '@typecad/passives/0805'` | | Connectors | `@typecad/passives/connector` | `import { Connector } from '@typecad/passives/connector'` | | Test Points | `@typecad/passives/testpoint` | `import { Testpoint } from '@typecad/passives/testpoint'` | | Core typeCAD classes | `@typecad/typecad` | `import { PCB, Power, Component } from '@typecad/typecad'` | ## Resistors, capacitors, LEDs, diodes, fuses, and inductors This package uses an options interface. Any parameter can be included or left out. They can be accessed and modified later in code. ```ts import { Schematic } from '@typecad/typecad' import { Resistor, LED, Capacitor, Diode, Inductor, Fuse } from '@typecad/passives/0805' import * as _0603 from '@typecad/passives/0603' let typecad = new Schematic('passives'); let resistor = new Resistor({ reference: "R1", value: "4.7 kOhm" }); let capacitor = new Capacitor({value: "100 nF", voltage: "6 V"}); let diode = new Diode(); let inductor = new Inductor({ value: "2.2 uH"}); let fuse = new Fuse({ reference: "F1" }); let led = new _0603.LED(); // a 0603 instead of 0805 typecad.create(resistor, led, capacitor, inductor, diode, fuse); ``` All of the sizes are: - `@typecad/passives/1210` - `@typecad/passives/1206` - `@typecad/passives/0805` - `@typecad/passives/0603` - `@typecad/passives/0402` - `@typecad/passives/0201` **no fuses* ### Auto designation If `{ reference }` is not included, the component will be auto-numbered. If there are any name collisions, the new name will be suffixed with a `_1`, ie `R1_1`. ## Connectors Connectors can be created similarly. ```ts import { Connector } from './module/passives/connector' // create a 10-pin connector using the JST footprint passed in the last parameter let j1 = new Connector({ number: 10, footprint:"Connector_JST:JST_SH_SM10B-SRSS-TB_1x10-1MP_P1.00mm_Horizontal" }); // create a 5-pin connector using a default 2.54 mm pin-header let j2 = new Connector({ number: 5 }); ``` ## Testpoints Testpoints can be created: ```ts import { Testpoint } from '@typecad/passives/testpoint'; let tp = new Testpoint(); ``` Will create a testpoint with a default footprint of `TestPoint:TestPoint_Pad_D1.0mm`. Specific footprints can be chosen: ```ts let tp = new Testpoint({ footprint: 'TestPoint:TestPoint_Keystone_5015_Micro_Mini'}); ``` Connect a testpoint using `tp.pin(1)` in the `::net()` method. --- ## Globals *@typecad/typecad* [**@typecad/typecad**](README.md) *** ## Enumerations - [RoutingAlgorithm](Enumeration.RoutingAlgorithm.md) ## Classes - [Component](Class.Component.md) - [DebugVisualizer](Class.DebugVisualizer.md) - [I2C](Class.I2C.md) - [KiCAD](Class.KiCAD.md) - [ObstacleBuilder](Class.ObstacleBuilder.md) - [PadResolver](Class.PadResolver.md) - [PCB](Class.PCB.md) - [Pin](Class.Pin.md) - [Power](Class.Power.md) - [RoutingGrid](Class.RoutingGrid.md) - [Schematic](Class.Schematic.md) - [TrackBuilder](Class.TrackBuilder.md) - [UART](Class.UART.md) - [USB](Class.USB.md) ## Interfaces - [IComponent](Interface.IComponent.md) - [IConnectionIdentifier](Interface.IConnectionIdentifier.md) - [IGridCell](Interface.IGridCell.md) - [IManualRoute](Interface.IManualRoute.md) - [IPadGeometry](Interface.IPadGeometry.md) - [IPinPowerInfo](Interface.IPinPowerInfo.md) - [IRoutingEngine](Interface.IRoutingEngine.md) - [IRoutingObstacle](Interface.IRoutingObstacle.md) - [KiCADCommandOptions](Interface.KiCADCommandOptions.md) ## Variables - [is\_flatpak](Variable.is_flatpak.md) - [kicad\_cli\_path](Variable.kicad_cli_path.md) - [kicad\_path](Variable.kicad_path.md) ## Functions - [executeKiCADCommand](Function.executeKiCADCommand.md) - [executeKiCADCommandSync](Function.executeKiCADCommandSync.md) - [exportPCB](Function.exportPCB.md) - [exportSchematic](Function.exportSchematic.md) - [runDRC](Function.runDRC.md) - [upgradeFootprint](Function.upgradeFootprint.md) --- ## PCB *Class: PCB* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / PCB Defined in: [pcb/pcb.ts:103](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L103) Represents a printed circuit board (PCB). ## Constructors ### Constructor > **new PCB**(`Boardname`, `options?`): `PCB` Defined in: [pcb/pcb.ts:132](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L132) Initializes a new PCB. #### Parameters ##### Boardname `string` Name and filename of generated files. ##### options? `IPcbOptions` #### Returns `PCB` ## Properties ### Boardname > **Boardname**: `string` Defined in: [pcb/pcb.ts:104](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L104) *** ### copper\_thickness > **copper\_thickness**: `number` Defined in: [pcb/pcb.ts:107](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L107) *** ### outlines > **outlines**: `IOutline`[] = `[]` Defined in: [pcb/pcb.ts:108](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L108) *** ### Schematic > **Schematic**: [`Schematic`](Class.Schematic.md) Defined in: [pcb/pcb.ts:105](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L105) *** ### thickness > **thickness**: `number` Defined in: [pcb/pcb.ts:106](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L106) *** ### tracks > **tracks**: `IOutline`[] = `[]` Defined in: [pcb/pcb.ts:109](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L109) ## Accessors ### components #### Get Signature > **get** **components**(): [`Component`](Class.Component.md)[] Defined in: [pcb/pcb.ts:301](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L301) Getter for components. ##### Returns [`Component`](Class.Component.md)[] *** ### existingBoardElements #### Get Signature > **get** **existingBoardElements**(): `any`[] Defined in: [pcb/pcb.ts:338](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L338) Getter for existing board elements. ##### Returns `any`[] *** ### grCircles #### Get Signature > **get** **grCircles**(): `IGrCircle`[] Defined in: [pcb/pcb.ts:259](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L259) Getter for graphics circles (required by PcbGraphicsInstance interface). ##### Returns `IGrCircle`[] *** ### grLines #### Get Signature > **get** **grLines**(): `IGrLine`[] Defined in: [pcb/pcb.ts:252](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L252) Getter for graphics lines (required by PcbGraphicsInstance interface). ##### Returns `IGrLine`[] *** ### groups #### Get Signature > **get** **groups**(): `string`[] Defined in: [pcb/pcb.ts:315](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L315) Getter for groups. ##### Returns `string`[] *** ### groupsAsMap #### Get Signature > **get** **groupsAsMap**(): `Map`\ Defined in: [pcb/pcb.ts:322](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L322) Getter for groups as Map (for footprint functions that expect Map). ##### Returns `Map`\ *** ### grPolys #### Get Signature > **get** **grPolys**(): `IGrPoly`[] Defined in: [pcb/pcb.ts:273](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L273) Getter for graphics polygons (required by PcbGraphicsInstance interface). ##### Returns `IGrPoly`[] *** ### grRects #### Get Signature > **get** **grRects**(): `IGrRect`[] Defined in: [pcb/pcb.ts:266](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L266) Getter for graphics rectangles (required by PcbGraphicsInstance interface). ##### Returns `IGrRect`[] *** ### grTexts #### Get Signature > **get** **grTexts**(): `IGrTextOptions`[] Defined in: [pcb/pcb.ts:345](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L345) Getter for grTexts. ##### Returns `IGrTextOptions`[] *** ### keepoutZones #### Get Signature > **get** **keepoutZones**(): `IKeepoutZone`[] Defined in: [pcb/pcb.ts:294](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L294) Getter for keepout zones. ##### Returns `IKeepoutZone`[] *** ### option #### Get Signature > **get** **option**(): `IPcbOptions` Defined in: [pcb/pcb.ts:245](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L245) Getter for PCB options. ##### Returns `IPcbOptions` *** ### options #### Get Signature > **get** **options**(): `IPcbOptions` Defined in: [pcb/pcb.ts:367](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L367) Getter for options. ##### Returns `IPcbOptions` *** ### outlines\_public #### Get Signature > **get** **outlines\_public**(): `IOutline`[] Defined in: [pcb/pcb.ts:360](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L360) Getter for outlines_public. ##### Returns `IOutline`[] *** ### pcb #### Get Signature > **get** **pcb**(): `string` Defined in: [pcb/pcb.ts:353](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L353) Getter for pcb string. ##### Returns `string` *** ### stagedComponents #### Get Signature > **get** **stagedComponents**(): [`Component`](Class.Component.md)[] Defined in: [pcb/pcb.ts:308](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L308) Getter for staged components. ##### Returns [`Component`](Class.Component.md)[] *** ### stagedOutlines #### Get Signature > **get** **stagedOutlines**(): `IOutline`[] Defined in: [pcb/pcb.ts:280](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L280) Getter for staged outlines (required by PcbGraphicsInstance interface). ##### Returns `IOutline`[] *** ### zones #### Get Signature > **get** **zones**(): `IFilledZone`[] Defined in: [pcb/pcb.ts:287](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L287) Getter for filled zones. ##### Returns `IFilledZone`[] ## Methods ### \_addComponentToBoardPublic() > **\_addComponentToBoardPublic**(`component`): `void` Defined in: [pcb/pcb.ts:508](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L508) **`Internal`** Public accessor for addComponentToBoard functionality. Used by extracted modules to add components to the board. #### Parameters ##### component [`Component`](Class.Component.md) Component to add to the board. #### Returns `void` *** ### \_clearComponents() > **\_clearComponents**(): `void` Defined in: [pcb/pcb.ts:550](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L550) **`Internal`** Public method to clear components. Used by extracted modules to reset components during board creation. #### Returns `void` *** ### \_clearGroups() > **\_clearGroups**(): `void` Defined in: [pcb/pcb.ts:568](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L568) **`Internal`** Public method to clear groups. Used by extracted modules to reset groups during board creation. #### Returns `void` *** ### \_clearOutlines() > **\_clearOutlines**(): `void` Defined in: [pcb/pcb.ts:559](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L559) **`Internal`** Public method to clear outlines. Used by extracted modules to reset outlines during board creation. #### Returns `void` *** ### \_createFootprintNodePublic() > **\_createFootprintNodePublic**(`component`, `boardNetNameToCodeMap?`): `any`[] Defined in: [pcb/pcb.ts:532](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L532) **`Internal`** Public accessor for createFootprintNode functionality. Used by extracted modules to create footprint nodes. #### Parameters ##### component [`Component`](Class.Component.md) ##### boardNetNameToCodeMap? `Map`\ #### Returns `any`[] *** ### \_getComponents() > **\_getComponents**(): [`Component`](Class.Component.md)[] Defined in: [pcb/pcb.ts:2928](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2928) **`Internal`** Get active components on the PCB. Used by ObstacleBuilder to include components as obstacles. #### Returns [`Component`](Class.Component.md)[] *** ### \_getKeepoutZones() > **\_getKeepoutZones**(): `IKeepoutZone`[] Defined in: [pcb/pcb.ts:2920](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2920) **`Internal`** Get keepout zones for obstacle detection during autorouting. Used by ObstacleBuilder to include keepout areas in the routing grid. #### Returns `IKeepoutZone`[] *** ### \_getStagedComponents() > **\_getStagedComponents**(): [`Component`](Class.Component.md)[] Defined in: [pcb/pcb.ts:2936](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2936) **`Internal`** Get staged components (placed but not yet created). Used by ObstacleBuilder to include staged components as obstacles. #### Returns [`Component`](Class.Component.md)[] *** ### \_getStagedOutlines() > **\_getStagedOutlines**(): `IOutline`[] Defined in: [pcb/pcb.ts:2912](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2912) **`Internal`** Get staged outlines for obstacle detection during autorouting. Used by ObstacleBuilder to detect tracks from previous autoroute calls. #### Returns `IOutline`[] *** ### \_removeStagedOutlinesByUuid() > **\_removeStagedOutlinesByUuid**(`uuids`): `void` Defined in: [pcb/pcb.ts:2943](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2943) **`Internal`** Remove staged outlines with specific UUIDs (used when reusing autoroute results in manual routes) #### Parameters ##### uuids `string`[] #### Returns `void` *** ### \_resolveNetPublic() > **\_resolveNetPublic**(`componentReference`, `pinNumber`, `componentUuid?`, `boardNetNameToCodeMap?`, `fallbackNetName?`): `INetResolution` Defined in: [pcb/pcb.ts:517](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L517) **`Internal`** Public accessor for resolveNet functionality. Used by extracted modules to resolve net assignments. #### Parameters ##### componentReference `string` ##### pinNumber `string` ##### componentUuid? `string` ##### boardNetNameToCodeMap? `Map`\ ##### fallbackNetName? `string` #### Returns `INetResolution` *** ### \_setPcb() > **\_setPcb**(`content`): `void` Defined in: [pcb/pcb.ts:577](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L577) **`Internal`** Public method to set PCB content. Used by extracted modules to set the PCB content. #### Parameters ##### content `string` #### Returns `void` *** ### \_track() > **\_track**(`start`, `end`, `width`, `layer`, `locked`, `uuid?`, `net?`): `string` Defined in: [pcb/pcb.ts:2951](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2951) **`Internal`** Generate a UUID for deferred staging #### Parameters ##### start ###### x `number` ###### y `number` ##### end ###### x `number` ###### y `number` ##### width `number` = `0.05` ##### layer `string` = `"F.Cu"` ##### locked `boolean` = `false` ##### uuid? `string` ##### net? `string` #### Returns `string` *** ### \_updateFootprintNodePublic() > **\_updateFootprintNodePublic**(`node`, `component`, `boardNetNameToCodeMap?`): `any`[] Defined in: [pcb/pcb.ts:541](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L541) **`Internal`** Public accessor for updateFootprintNode functionality. Used by extracted modules to update footprint nodes. #### Parameters ##### node `any`[] ##### component [`Component`](Class.Component.md) ##### boardNetNameToCodeMap? `Map`\ #### Returns `any`[] *** ### add() > **add**(...`components`): `void` Defined in: [pcb/pcb.ts:3319](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3319) Adds components to the associated schematic. This is a pass-through to the Schematic.add() method. #### Parameters ##### components ...[`Component`](Class.Component.md)[] Components to add to the schematic. #### Returns `void` *** ### autorouteBatch() > **autorouteBatch**(`items`, `batchOptions?`): `Promise`\ Defined in: [pcb/pcb.ts:3140](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3140) Batch autorouter orchestrator with simple rip-up-and-retry. Routes multiple connections together, retrying with different ordering and relaxed parameters across rounds to negotiate congestion. #### Parameters ##### items `object`[] ##### batchOptions? ###### increaseIterationsPerRound? `number` ###### relaxViaCostPerRound? `number` ###### reorder? `"reverse"` \| `"none"` \| `"byDistance"` ###### rounds? `number` #### Returns `Promise`\ *** ### bom() > **bom**(`output_folder?`): `void` Defined in: [pcb/pcb.ts:3298](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3298) Generates a Bill of Materials (BOM) for the associated schematic. This is a pass-through to the Schematic.bom() method. #### Parameters ##### output\_folder? `string` The folder to output the BOM to. #### Returns `void` *** ### circle() > **circle**(`options`): `void` Defined in: [pcb/pcb.ts:2766](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2766) Creates a graphical circle on the board. #### Parameters ##### options Circle configuration options ###### center \{ `x`: `number`; `y`: `number`; \} Center point coordinates {x, y} ###### center.x `number` ###### center.y `number` ###### end? \{ `x`: `number`; `y`: `number`; \} Radius endpoint coordinates {x, y} (alternative to radius) ###### end.x `number` ###### end.y `number` ###### fill? `boolean` Fill the circle (default: false) ###### layer? `string` Layer name (default: 'F.SilkS') ###### locked? `boolean` Lock the circle to prevent editing (default: false) ###### radius? `number` Circle radius (alternative to using end point) ###### width? `number` Outline width/thickness (default: 0.15mm) #### Returns `void` #### Example ```ts // Circle with radius pcb.circle({ center: { x: 50, y: 50 }, radius: 10 }); // Filled circle on copper layer pcb.circle({ center: { x: 30, y: 30 }, radius: 5, layer: 'F.Cu', width: 0.2, fill: true }); // Circle using endpoint (radius point) pcb.circle({ center: { x: 0, y: 0 }, end: { x: 10, y: 0 }, // Radius = 10 layer: 'Dwgs.User' }); ``` *** ### create() > **create**(...`items`): `Promise`\ Defined in: [pcb/pcb.ts:2082](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2082) Creates and saves the board to a file. #### Parameters ##### items ...([`Component`](Class.Component.md) \| [`TrackBuilder`](Class.TrackBuilder.md))[] Components and TrackBuilder instances to add to the board before creating. #### Returns `Promise`\ *** ### createRouter() > **createRouter**(`name`, `grid`, `options`): `any` Defined in: [pcb/pcb.ts:186](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L186) **`Internal`** Create a routing engine by name from this PCB instance's registry. #### Parameters ##### name `string` ##### grid [`RoutingGrid`](Class.RoutingGrid.md) ##### options `unknown` #### Returns `any` *** ### getCallSite() > **getCallSite**(): `undefined` \| \{ `column`: `number`; `file`: `string`; `line`: `number`; \} Defined in: [pcb/pcb.ts:2086](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2086) #### Returns `undefined` \| \{ `column`: `number`; `file`: `string`; `line`: `number`; \} *** ### getRegisteredRouters() > **getRegisteredRouters**(): `string`[] Defined in: [pcb/pcb.ts:206](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L206) **`Internal`** Get the list of registered router names from this PCB instance's registry. #### Returns `string`[] *** ### getRouterGridConfigurator() > **getRouterGridConfigurator**(`name`): `undefined` \| (`context`) => `void` \| \{ `gridResolution?`: `number`; `reason?`: `string`; \} Defined in: [pcb/pcb.ts:198](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L198) **`Internal`** Get the grid configuration hook for an algorithm from this PCB instance's registry. #### Parameters ##### name `string` #### Returns `undefined` \| (`context`) => `void` \| \{ `gridResolution?`: `number`; `reason?`: `string`; \} *** ### group() > **group**(`group_name`, ...`items`): `void` Defined in: [pcb/pcb.ts:640](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L640) Groups components and/or elements from a TrackBuilder together on the board. #### Parameters ##### group\_name `string` Name of the group. ##### items ...([`Component`](Class.Component.md) \| [`TrackBuilder`](Class.TrackBuilder.md))[] A list of Component instances or TrackBuilder instances. #### Returns `void` *** ### keepout() > **keepout**(`options`): `void` Defined in: [pcb/pcb.ts:2660](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2660) Creates a keepout zone that restricts routing and placement. #### Parameters ##### options Keepout zone configuration options ###### hatchPitch? `number` Hatch pitch/spacing (default: 0.508mm) ###### hatchStyle? `"none"` \| `"edge"` \| `"full"` Hatch style for zone outline: 'none', 'edge' (default), or 'full' ###### height `number` The height of the keepout zone ###### layers `string`[] Array of layer names (e.g., ['F.Cu', 'B.Cu']) ###### locked? `boolean` Lock zone to prevent editing (default: false) ###### name? `string` Optional zone name ###### priority? `number` Zone priority (default: 0) ###### restrictions? \{ `copperpour?`: `boolean`; `footprints?`: `boolean`; `pads?`: `boolean`; `tracks?`: `boolean`; `vias?`: `boolean`; \} Object specifying what to restrict (all default to true) ###### restrictions.copperpour? `boolean` Restrict copper pour (default: true) ###### restrictions.footprints? `boolean` Restrict footprints (default: true) ###### restrictions.pads? `boolean` Restrict pads (default: true) ###### restrictions.tracks? `boolean` Restrict tracks (default: true) ###### restrictions.vias? `boolean` Restrict vias (default: true) ###### smoothing? `"none"` \| `"chamfer"` \| `"fillet"` Corner smoothing: 'chamfer', 'fillet', or 'none' (default) ###### smoothingRadius? `number` Radius for corner smoothing (required if smoothing is set) ###### width `number` The width of the keepout zone ###### x `number` The x-coordinate of the keepout zone's starting corner ###### y `number` The y-coordinate of the keepout zone's starting corner #### Returns `void` #### Example ```ts // ============================================ // BASIC EXAMPLES // ============================================ // Basic keepout (restricts everything) pcb.keepout({ layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 10, height: 10 }); // ============================================ // CUSTOM RESTRICTIONS // ============================================ // Restrict only tracks and vias, allow pads pcb.keepout({ layers: ['F.Cu'], x: 5, y: 5, width: 8, height: 8, restrictions: { tracks: true, vias: true, pads: false, copperpour: true, footprints: false } }); // Restrict only copper pour (allow routing) pcb.keepout({ layers: ['F.Cu'], x: 10, y: 10, width: 15, height: 15, restrictions: { tracks: false, vias: false, pads: false, copperpour: true, footprints: false } }); // ============================================ // ZONE MANAGEMENT OPTIONS // ============================================ // Named, locked keepout with priority pcb.keepout({ layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 20, height: 20, name: 'Antenna Keepout', locked: true, priority: 10 }); // High-priority keepout area pcb.keepout({ layers: ['F.Cu'], x: 0, y: 0, width: 30, height: 30, name: 'Critical Area', priority: 100 }); // ============================================ // CORNER SMOOTHING // ============================================ // Filleted corners pcb.keepout({ layers: ['F.Cu'], x: 0, y: 0, width: 15, height: 15, smoothing: 'fillet', smoothingRadius: 0.5, name: 'Smooth Keepout' }); // Chamfered corners pcb.keepout({ layers: ['B.Cu'], x: 0, y: 0, width: 15, height: 15, smoothing: 'chamfer', smoothingRadius: 0.3 }); // ============================================ // HATCH DISPLAY SETTINGS // ============================================ // No hatch display (invisible outline) pcb.keepout({ layers: ['F.Cu'], x: 0, y: 0, width: 10, height: 10, hatchStyle: 'none' }); // Edge hatch with custom spacing pcb.keepout({ layers: ['F.Cu'], x: 0, y: 0, width: 10, height: 10, hatchStyle: 'edge', hatchPitch: 1.0 }); // Full hatch fill pcb.keepout({ layers: ['F.Cu'], x: 0, y: 0, width: 10, height: 10, hatchStyle: 'full', hatchPitch: 0.5 }); // ============================================ // COMPREHENSIVE EXAMPLE (all options) // ============================================ pcb.keepout({ // Position and layers layers: ['F.Cu', 'B.Cu'], x: 20, y: 20, width: 30, height: 25, // Zone management name: 'High Priority Antenna Area', locked: true, priority: 50, // Restrictions (customize what's not allowed) restrictions: { tracks: true, // Don't allow tracks vias: true, // Don't allow vias pads: false, // Allow pads copperpour: true, // Don't allow copper pour footprints: true // Don't allow footprints }, // Corner smoothing smoothing: 'fillet', smoothingRadius: 1.0, // Hatch display hatchStyle: 'edge', hatchPitch: 0.508 }); ``` *** ### line() > **line**(`options`): `void` Defined in: [pcb/pcb.ts:2724](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2724) Creates a graphical line on the board. #### Parameters ##### options Line configuration options ###### end \{ `x`: `number`; `y`: `number`; \} Ending point coordinates {x, y} ###### end.x `number` ###### end.y `number` ###### layer? `string` Layer name (default: 'F.SilkS') ###### locked? `boolean` Lock the line to prevent editing (default: false) ###### start \{ `x`: `number`; `y`: `number`; \} Starting point coordinates {x, y} ###### start.x `number` ###### start.y `number` ###### width? `number` Line width/thickness (default: 0.15mm) #### Returns `void` #### Example ```ts // Basic line on front silkscreen pcb.line({ start: { x: 0, y: 0 }, end: { x: 10, y: 10 } }); // Line on edge cuts with custom width pcb.line({ start: { x: 0, y: 0 }, end: { x: 100, y: 0 }, layer: 'Edge.Cuts', width: 0.1 }); // Locked line on user drawings layer pcb.line({ start: { x: 20, y: 20 }, end: { x: 80, y: 80 }, layer: 'Dwgs.User', width: 0.2, locked: true }); ``` *** ### named() > **named**(`name`): `this` Defined in: [pcb/pcb.ts:3287](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3287) Sets a name for a net in the associated schematic. This is a pass-through to the Schematic.named() method. #### Parameters ##### name `string` The name to set for the net. #### Returns `this` The PCB instance for chaining. *** ### net() > **net**(...`pins`): `ISchematicNetDefinition` Defined in: [pcb/pcb.ts:3277](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3277) Connects a group of pins together in the associated schematic. Returns a description of the resulting net so it can be reused later. #### Parameters ##### pins ...[`Pin`](Class.Pin.md)[] Pins to connect in the net. #### Returns `ISchematicNetDefinition` *** ### outline() > **outline**(`x`, `y`, `width`, `height`, `filletRadius`, `conceptualUuidFromUser?`): `void` Defined in: [pcb/pcb.ts:2904](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2904) Creates a rectangular outline on the Edge.Cuts layer. #### Parameters ##### x `number` The x-coordinate of the rectangle's start point. ##### y `number` The y-coordinate of the rectangle's start point. ##### width `number` The width of the rectangle. ##### height `number` The height of the rectangle. ##### filletRadius `number` = `0` The radius for filleted corners (0 for sharp). ##### conceptualUuidFromUser? `string` Optional UUID for the conceptual outline. #### Returns `void` *** ### place() > **place**(...`components`): `void` Defined in: [pcb/pcb.ts:585](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L585) Places components on the board. #### Parameters ##### components ...[`Component`](Class.Component.md)[] List of components to place. #### Returns `void` *** ### poly() > **poly**(`options`): `void` Defined in: [pcb/pcb.ts:2885](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2885) Creates a graphical polygon on the board. #### Parameters ##### options Polygon configuration options ###### fill? `boolean` Fill the polygon (default: false) ###### layer? `string` Layer name (default: 'F.SilkS') ###### locked? `boolean` Lock the polygon to prevent editing (default: false) ###### points `object`[] Array of vertex coordinates [{x, y}, ...] ###### width? `number` Outline width/thickness (default: 0.15mm) #### Returns `void` #### Example ```ts // Triangle pcb.poly({ points: [ { x: 0, y: 0 }, { x: 10, y: 0 }, { x: 5, y: 10 } ] }); // Filled hexagon on copper layer pcb.poly({ points: [ { x: 50, y: 40 }, { x: 60, y: 45 }, { x: 60, y: 55 }, { x: 50, y: 60 }, { x: 40, y: 55 }, { x: 40, y: 45 } ], layer: 'F.Cu', width: 0.2, fill: true }); // Pentagon on user drawings layer pcb.poly({ points: [ { x: 100, y: 90 }, { x: 110, y: 95 }, { x: 108, y: 105 }, { x: 92, y: 105 }, { x: 90, y: 95 } ], layer: 'Dwgs.User', width: 0.15, locked: true }); ``` *** ### rect() > **rect**(`options`): `void` Defined in: [pcb/pcb.ts:2821](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2821) Creates a graphical rectangle on the board. #### Parameters ##### options Rectangle configuration options ###### end? \{ `x`: `number`; `y`: `number`; \} Bottom-right corner coordinates {x, y} (alternative to width/height) ###### end.x `number` ###### end.y `number` ###### fill? `boolean` Fill the rectangle (default: false) ###### height? `number` Rectangle height (alternative to end) ###### layer? `string` Layer name (default: 'F.SilkS') ###### locked? `boolean` Lock the rectangle to prevent editing (default: false) ###### start? \{ `x`: `number`; `y`: `number`; \} Top-left corner coordinates {x, y} (alternative to x/y) ###### start.x `number` ###### start.y `number` ###### strokeWidth? `number` Outline width/thickness (default: 0.15mm) ###### width? `number` Rectangle width (alternative to end) ###### x? `number` X-coordinate of top-left corner (alternative to start) ###### y? `number` Y-coordinate of top-left corner (alternative to start) #### Returns `void` #### Example ```ts // Rectangle using x, y, width, height pcb.rect({ x: 10, y: 10, width: 30, height: 20 }); // Filled rectangle on copper layer pcb.rect({ x: 50, y: 50, width: 40, height: 30, layer: 'F.Cu', strokeWidth: 0.2, fill: true }); // Rectangle using start and end points pcb.rect({ start: { x: 0, y: 0 }, end: { x: 100, y: 80 }, layer: 'Dwgs.User' }); // Locked outline rectangle pcb.rect({ x: 5, y: 5, width: 90, height: 70, layer: 'Edge.Cuts', strokeWidth: 0.1, locked: true }); ``` *** ### registerRouter() > **registerRouter**(`registerFn`): `void` Defined in: [pcb/pcb.ts:149](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L149) Register a routing algorithm with this PCB instance. #### Parameters ##### registerFn (`registry`, `algorithm?`) => `void` A registerRouter function (e.g., from @typecad-astar) #### Returns `void` *** ### resolveNet() > **resolveNet**(`componentReference`, `pinNumber`, `componentUuid?`, `boardNetNameToCodeMap?`, `fallbackNetName?`): `INetResolution` Defined in: [pcb/pcb.ts:379](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L379) Public resolveNet method that delegates to the private implementation. This is needed for the extracted functions that expect a public resolveNet method. #### Parameters ##### componentReference `string` ##### pinNumber `string` ##### componentUuid? `string` ##### boardNetNameToCodeMap? `Map`\ ##### fallbackNetName? `string` #### Returns `INetResolution` *** ### route() #### Call Signature > **route**(`options`): `Promise`\ Defined in: [pcb/pcb.ts:3107](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3107) Unified routing API. Overloads: - Route specific pins: route({ from: U1.pin(1), to: [U2.pin(1)], width: 0.5 }) - Route a named net: route(netDefinition, { gridResolution: 0.15 }) ##### Parameters ###### options `IAutorouteOptions` ##### Returns `Promise`\ #### Call Signature > **route**(`netDefinition`, `options?`): `Promise`\ Defined in: [pcb/pcb.ts:3108](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L3108) Unified routing API. Overloads: - Route specific pins: route({ from: U1.pin(1), to: [U2.pin(1)], width: 0.5 }) - Route a named net: route(netDefinition, { gridResolution: 0.15 }) ##### Parameters ###### netDefinition `ISchematicNetDefinition` ###### options? `IAutorouteRouteOptions` ##### Returns `Promise`\ *** ### stage() > **stage**(...`components`): `void` Defined in: [pcb/pcb.ts:596](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L596) Stage components so they're considered for routing/debug before full board creation. #### Parameters ##### components ...[`Component`](Class.Component.md)[] Components to stage #### Returns `void` *** ### text() > **text**(`options`): `void` Defined in: [pcb/pcb.ts:704](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L704) Adds board-level text (gr_text) to the PCB. #### Parameters ##### options `IGrTextOptions` Text options including content, position, layer, and formatting #### Returns `void` #### Example ```ts pcb.text({ text: 'TYPECAD 1HZ', x: 145.415, y: 108.585, rotation: 0, layer: 'F.SilkS', font: 'Super Skinny Pixel Bricks', width: 5, height: 5 }); ``` *** ### track() > **track**(`options?`): [`TrackBuilder`](Class.TrackBuilder.md) Defined in: [pcb/pcb.ts:2994](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2994) Begins a fluent interface for creating connected tracks and vias. #### Parameters ##### options? ###### deferStaging? `boolean` ###### locked? `boolean` ###### net? `string` #### Returns [`TrackBuilder`](Class.TrackBuilder.md) A TrackBuilder instance. Example: ``` let power_track_elements = pcb.connect() .from({x: 100, y: 100}, "F.Cu", 0.2) .to({x: 110, y: 100}) .via({size: 0.8, drill: 0.4}) // Transitions to B.Cu (or other side of via) .to({x: 110, y: 120, layer: "B.Cu"}) // Continues on B.Cu ``` *** ### via() > **via**(`via`): [`Component`](Class.Component.md) Defined in: [pcb/pcb.ts:2154](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2154) Handles via-related operations. #### Parameters ##### via `Omit`\ = `{}` The via details. #### Returns [`Component`](Class.Component.md) The component representing the via. *** ### zone() > **zone**(`options`): `void` Defined in: [pcb/pcb.ts:2437](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb.ts#L2437) Creates a filled zone on copper layers connected to a specific net. #### Parameters ##### options Zone configuration options ###### clearance? `number` Clearance from pads (default: 0.2mm) ###### connectPads? `"full"` \| `"thru_hole_only"` \| `"no"` Pad connection type (default: thermal relief) ###### fillArcSegments? `number` Number of segments for curved fills (default: 16) ###### filled? `boolean` Whether zone should be filled (default: true) ###### filledAreasThickness? `boolean` Control line width in fill area calculations ###### fillMode? `"solid"` \| `"hatched"` Fill mode: 'solid' (default) or 'hatched' ###### hatchBorderAlgorithm? `"hatch_thickness"` \| `"min_thickness"` Border algorithm: 'hatch_thickness' or 'min_thickness' ###### hatchGap? `number` Gap between hatch lines ###### hatchMinHoleArea? `number` Minimum hole area for hatching ###### hatchOrientation? `number` Hatch line angle in degrees ###### hatchPitch? `number` Hatch pitch/spacing (default: 0.508mm) ###### hatchSmoothingLevel? `number` Hatch smoothing level 0-3 ###### hatchSmoothingValue? `number` Hatch smoothing value ###### hatchStyle? `"none"` \| `"edge"` \| `"full"` Hatch style for zone outline: 'none', 'edge' (default), or 'full' ###### hatchThickness? `number` Line thickness for hatched fills ###### height `number` The height of the zone ###### islandAreaMin? `number` Minimum island area (required if islandRemovalMode is 2) ###### islandRemovalMode? `number` Island removal: 0 (always), 1 (never), 2 (below min area) ###### layers `string`[] Array of layer names (e.g., ['F.Cu', 'B.Cu']) ###### locked? `boolean` Lock zone to prevent editing (default: false) ###### minThickness? `number` Minimum thickness (default: 0.1778mm) ###### name? `string` Optional zone name ###### net? `string` The net name to connect this zone to (e.g., 'GND', 'VCC'). Use either pin or net, not both. ###### pin? `any` The pin object to connect this zone to (determines the net). Use either pin or net, not both. ###### priority? `number` Zone priority (default: 0) ###### smoothing? `"none"` \| `"chamfer"` \| `"fillet"` Corner smoothing: 'chamfer', 'fillet', or 'none' (default) ###### smoothingRadius? `number` Radius for corner smoothing (required if smoothing is set) ###### thermalBridgeWidth? `number` Thermal bridge width (default: 0.4064mm) ###### thermalGap? `number` Thermal relief gap (default: 0.254mm) ###### width `number` The width of the zone ###### x `number` The x-coordinate of the zone's starting corner ###### y `number` The y-coordinate of the zone's starting corner #### Returns `void` #### Example ```ts // ============================================ // BASIC EXAMPLES // ============================================ // Basic GND zone (minimal parameters) pcb.zone({ net: 'GND', layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 50, height: 40 }); // Using pin instead of net name pcb.zone({ pin: U4.pin(10), layers: ['F.Cu'], x: 10, y: 10, width: 20, height: 20 }); // ============================================ // ZONE MANAGEMENT OPTIONS // ============================================ // Named, locked zone with priority pcb.zone({ net: 'VCC', layers: ['F.Cu'], x: 0, y: 0, width: 30, height: 30, name: 'Power Zone', locked: true, priority: 10 }); // ============================================ // FILL SETTINGS // ============================================ // Solid fill with custom thermal relief pcb.zone({ net: 'GND', layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 50, height: 50, fillMode: 'solid', filled: true, thermalGap: 0.3, thermalBridgeWidth: 0.5, fillArcSegments: 32 }); // Hatched fill with full customization pcb.zone({ net: 'SIGNAL', layers: ['F.Cu'], x: 0, y: 0, width: 20, height: 20, fillMode: 'hatched', hatchThickness: 0.2, hatchGap: 0.5, hatchOrientation: 45, hatchSmoothingLevel: 2, hatchSmoothingValue: 0.1, hatchBorderAlgorithm: 'hatch_thickness', hatchMinHoleArea: 0.01 }); // ============================================ // PAD CONNECTION OPTIONS // ============================================ // Full pad connection (no thermal relief) pcb.zone({ net: 'GND', layers: ['F.Cu'], x: 0, y: 0, width: 40, height: 40, connectPads: 'full', clearance: 0.3 }); // Through-hole only connection pcb.zone({ net: 'VCC', layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 40, height: 40, connectPads: 'thru_hole_only', clearance: 0.2 }); // No pad connection pcb.zone({ net: 'SHIELD', layers: ['F.Cu'], x: 0, y: 0, width: 40, height: 40, connectPads: 'no', clearance: 0.5 }); // ============================================ // CORNER SMOOTHING // ============================================ // Filleted corners pcb.zone({ net: 'GND', layers: ['F.Cu'], x: 0, y: 0, width: 30, height: 30, smoothing: 'fillet', smoothingRadius: 0.5 }); // Chamfered corners pcb.zone({ net: 'VCC', layers: ['B.Cu'], x: 0, y: 0, width: 30, height: 30, smoothing: 'chamfer', smoothingRadius: 0.3 }); // ============================================ // ISLAND REMOVAL // ============================================ // Always remove islands pcb.zone({ net: 'GND', layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 50, height: 50, islandRemovalMode: 0 }); // Never remove islands pcb.zone({ net: 'ANTENNA', layers: ['F.Cu'], x: 0, y: 0, width: 20, height: 20, islandRemovalMode: 1 }); // Remove islands below minimum area pcb.zone({ net: 'GND', layers: ['F.Cu'], x: 0, y: 0, width: 50, height: 50, islandRemovalMode: 2, islandAreaMin: 0.5 // Remove islands smaller than 0.5mm² }); // ============================================ // HATCH DISPLAY SETTINGS (for zone outline) // ============================================ // No hatch display pcb.zone({ net: 'GND', layers: ['F.Cu'], x: 0, y: 0, width: 40, height: 40, hatchStyle: 'none' }); // Edge hatch with custom spacing pcb.zone({ net: 'VCC', layers: ['F.Cu'], x: 0, y: 0, width: 40, height: 40, hatchStyle: 'edge', hatchPitch: 1.0 }); // Full hatch pcb.zone({ net: 'SHIELD', layers: ['F.Cu'], x: 0, y: 0, width: 40, height: 40, hatchStyle: 'full', hatchPitch: 0.5 }); // ============================================ // COMPREHENSIVE EXAMPLE (all options) // ============================================ pcb.zone({ // Net specification net: 'GND', // Position and layers layers: ['F.Cu', 'B.Cu'], x: 0, y: 0, width: 100, height: 80, // Zone management name: 'Main Ground Plane', locked: true, priority: 5, // Fill settings fillMode: 'solid', filled: true, minThickness: 0.2, fillArcSegments: 32, // Thermal relief thermalGap: 0.3, thermalBridgeWidth: 0.5, // Pad connection connectPads: 'thru_hole_only', clearance: 0.25, // Corner smoothing smoothing: 'fillet', smoothingRadius: 1.0, // Island removal islandRemovalMode: 2, islandAreaMin: 0.5, // Hatch display hatchStyle: 'edge', hatchPitch: 0.508 }); ``` --- ## Schematic *Class: Schematic* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Schematic Defined in: [schematic.ts:133](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L133) The main class for typeCAD. Holds all [Component](Class.Component.md) classes, creates work files, and creates nets. ## Export Schematic ## Constructors ### Constructor > **new Schematic**(`Sheetname`): `Schematic` Defined in: [schematic.ts:242](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L242) Initializes a new schematic with a given sheet name. #### Parameters ##### Sheetname `string` Name and filename of generated files. #### Returns `Schematic` #### Example ```ts let typecad = new Schematic('sheetname'); ``` ## Properties ### Components > **Components**: [`Component`](Class.Component.md)[] = `[]` Defined in: [schematic.ts:134](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L134) *** ### merged\_nets > **merged\_nets**: `object`[] = `[]` Defined in: [schematic.ts:141](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L141) #### merged\_to\_number > **merged\_to\_number**: `number` #### old\_name > **old\_name**: `string` *** ### Nodes > **Nodes**: `object`[] = `[]` Defined in: [schematic.ts:140](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L140) #### code > **code**: `number` #### name > **name**: `string` #### nodes > **nodes**: [`Pin`](Class.Pin.md)[] #### owner > **owner**: `null` \| [`Component`](Class.Component.md) *** ### Sheetname > **Sheetname**: `string` = `''` Defined in: [schematic.ts:135](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L135) *** ### uuid > **uuid**: `` `${string}-${string}-${string}-${string}-${string}` `` Defined in: [schematic.ts:136](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L136) ## Accessors ### option #### Get Signature > **get** **option**(): `ISchematicOptions` Defined in: [schematic.ts:160](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L160) Getter for Schematic options. ##### Example ```ts let schematic = new Schematic('sheetname'); schematic.option.safe_write = false; schematic.option.build_dir = './custom_build/'; ``` ##### Returns `ISchematicOptions` ## Methods ### add() > **add**(...`components`): `void` Defined in: [schematic.ts:258](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L258) Adds components to the schematic. #### Parameters ##### components ...[`Component`](Class.Component.md)[] Components to add to the schematic. #### Returns `void` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); typecad.add(r1, r2); ``` *** ### bom() > **bom**(`output_folder?`): `undefined` \| `false` Defined in: [schematic.ts:192](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L192) #### Parameters ##### output\_folder? `string` #### Returns `undefined` \| `false` *** ### create() > **create**(...`component`): `undefined` \| `false` Defined in: [schematic.ts:533](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L533) Creates schematic files. #### Parameters ##### component ...[`Component`](Class.Component.md)[] #### Returns `undefined` \| `false` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); typecad.create(r1, r2); ``` *** ### dnc() > **dnc**(...`pins`): `void` Defined in: [schematic.ts:348](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L348) Adds a no-connection flag to a pin. #### Parameters ##### pins ...[`Pin`](Class.Pin.md)[] Pins to mark as no-connect. #### Returns `void` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Resistor({ symbol: "Device:R_Small", reference: 'R1' }); typecad.dnc(r1.pin(1)); ``` *** ### erc() > **erc**(): `void` Defined in: [schematic.ts:562](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L562) Performs electrical rule checks. #### Returns `void` *** ### error() > **error**(`error`): `void` Defined in: [schematic.ts:571](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L571) Logs an error message and exits. #### Parameters ##### error `string` The error message to log. #### Returns `void` *** ### named() > **named**(`name`): `Schematic` Defined in: [schematic.ts:372](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L372) Sets a name for a net. #### Parameters ##### name `string` #### Returns `Schematic` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); // named net typecad.named('vin').net(r1.pin(1), r2.pin(1)); // unnamed net typecad.net(r1.pin(1), r2.pin(1)); ``` *** ### net() > **net**(...`pins`): `ISchematicNetDefinition` Defined in: [schematic.ts:394](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L394) Connects a group of pins together. #### Parameters ##### pins ...[`Pin`](Class.Pin.md)[] Pins to connect. #### Returns `ISchematicNetDefinition` #### Example ```ts let typecad = new Schematic('sheetname'); let r1 = new Component({}); let r2 = new Component({}); // named net typecad.named('vin').net(r1.pin(1), r2.pin(1)); // unnamed net typecad.net(r1.pin(1), r2.pin(1)); ``` *** ### warn() > **warn**(`warning`): `void` Defined in: [schematic.ts:581](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/schematic.ts#L581) Logs a warning message. #### Parameters ##### warning `string` The warning message to log. #### Returns `void` --- ## Component *Class: Component* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Component Defined in: [component.ts:63](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L63) Represents a component in an electronic circuit. ## Constructors ### Constructor > **new Component**(`options?`): `Component` Defined in: [component.ts:97](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L97) Creates an instance of Component. #### Parameters ##### options? [`IComponent`](Interface.IComponent.md) = `{}` The component options. #### Returns `Component` ## Properties ### datasheet > **datasheet**: `string` = `''` Defined in: [component.ts:67](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L67) Link to component datasheet. *** ### description > **description**: `string` = `''` Defined in: [component.ts:68](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L68) Description of the component. *** ### dnp > **dnp**: `boolean` = `false` Defined in: [component.ts:73](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L73) True if Do Not Place. *** ### fab? > `optional` **fab**: `object` Defined in: [component.ts:85](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L85) #### bold? > `optional` **bold**: `boolean` #### fontSize? > `optional` **fontSize**: `number` #### height? > `optional` **height**: `number` #### italic? > `optional` **italic**: `boolean` #### justify? > `optional` **justify**: `object` ##### justify.horizontal? > `optional` **horizontal**: `"center"` \| `"left"` \| `"right"` ##### justify.mirror? > `optional` **mirror**: `boolean` ##### justify.vertical? > `optional` **vertical**: `"top"` \| `"bottom"` \| `"middle"` #### layer? > `optional` **layer**: `string` #### rotation? > `optional` **rotation**: `number` #### show? > `optional` **show**: `boolean` #### text > **text**: `string` #### thickness? > `optional` **thickness**: `number` #### width? > `optional` **width**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### footprint > **footprint**: `string` = `''` Defined in: [component.ts:66](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L66) Component footprint (e.g., Resistor_SMD:R_0603_1608Metric). *** ### groups > **groups**: `string`[] = `[]` Defined in: [component.ts:82](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L82) *** ### mpn > **mpn**: `string` = `''` Defined in: [component.ts:71](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L71) Manufacturer Part Number. *** ### pcb > **pcb**: `object` Defined in: [component.ts:72](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L72) PCB placement details (x, y, rotation). #### rotation? > `optional` **rotation**: `number` #### side? > `optional` **side**: `"front"` \| `"back"` #### x > **x**: `number` #### y > **y**: `number` *** ### pins > **pins**: [`Pin`](Class.Pin.md)[] = `[]` Defined in: [component.ts:76](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L76) Array of component pins. *** ### reference > **reference**: `string` = `''` Defined in: [component.ts:64](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L64) Reference designator (e.g., R1) or a tuple with positioning info (e.g., ['U2', {x: 1, y: 1, rotation: 0}]). When provided as a tuple, the positioning controls where the reference text appears in KiCad. *** ### sch > **sch**: `object` Defined in: [component.ts:81](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L81) #### rotation? > `optional` **rotation**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### simulation > **simulation**: `object` Defined in: [component.ts:79](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L79) Simulation details. #### include > **include**: `boolean` #### model > **model**: `string` *** ### sourceInfo? > `optional` **sourceInfo**: `SourceInfo` Defined in: [component.ts:83](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L83) Source code location and instantiation details where the component was created, parsed via AST. Includes file path, line number, variable name (if in declaration like `let r1 = new Component()`), and fully structured parameters (supports nested objects/arrays from `{value: '10k', sim: {include: true}}`). *** ### symbol? > `optional` **symbol**: `string` = `''` Defined in: [component.ts:80](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L80) *** ### text > **text**: `object`[] = `[]` Defined in: [component.ts:84](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L84) #### bold? > `optional` **bold**: `boolean` #### fontSize? > `optional` **fontSize**: `number` #### height? > `optional` **height**: `number` #### italic? > `optional` **italic**: `boolean` #### justify? > `optional` **justify**: `object` ##### justify.horizontal? > `optional` **horizontal**: `"center"` \| `"left"` \| `"right"` ##### justify.mirror? > `optional` **mirror**: `boolean` ##### justify.vertical? > `optional` **vertical**: `"top"` \| `"bottom"` \| `"middle"` #### layer? > `optional` **layer**: `string` #### property > **property**: `string` #### rotation? > `optional` **rotation**: `number` #### show? > `optional` **show**: `boolean` #### text > **text**: `string` #### thickness? > `optional` **thickness**: `number` #### width? > `optional` **width**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### value > **value**: `string` = `''` Defined in: [component.ts:65](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L65) Component value (e.g., 1 kOhm) or a tuple with positioning info (e.g., ['10k', {x: 0, y: 5, rotation: 0}]). When provided as a tuple, the positioning controls where the value text appears in KiCad. *** ### valueFootprint? > `optional` **valueFootprint**: `object` Defined in: [component.ts:86](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L86) #### bold? > `optional` **bold**: `boolean` #### fontSize? > `optional` **fontSize**: `number` #### height? > `optional` **height**: `number` #### italic? > `optional` **italic**: `boolean` #### justify? > `optional` **justify**: `object` ##### justify.horizontal? > `optional` **horizontal**: `"center"` \| `"left"` \| `"right"` ##### justify.mirror? > `optional` **mirror**: `boolean` ##### justify.vertical? > `optional` **vertical**: `"top"` \| `"bottom"` \| `"middle"` #### layer? > `optional` **layer**: `string` #### rotation? > `optional` **rotation**: `number` #### show? > `optional` **show**: `boolean` #### thickness? > `optional` **thickness**: `number` #### width? > `optional` **width**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### via > **via**: `boolean` = `false` Defined in: [component.ts:77](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L77) True if the component is a via. *** ### viaData? > `optional` **viaData**: `IVia` Defined in: [component.ts:78](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L78) *** ### voltage > **voltage**: `string` = `''` Defined in: [component.ts:69](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L69) *** ### wattage > **wattage**: `string` = `''` Defined in: [component.ts:70](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L70) ## Accessors ### uuid #### Get Signature > **get** **uuid**(): `string` Defined in: [component.ts:738](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L738) Get the UUID for this component. If not explicitly set, it will be generated consistently based on component properties. ##### Returns `string` #### Set Signature > **set** **uuid**(`value`): `void` Defined in: [component.ts:761](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L761) Set the UUID for this component ##### Parameters ###### value `string` ##### Returns `void` Unique identifier. ## Methods ### getGroups() > **getGroups**(): `string`[] Defined in: [component.ts:808](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L808) Get all groups this component belongs to. #### Returns `string`[] Array of group names this component is a member of. *** ### isInGroup() > **isInGroup**(`groupName`): `boolean` Defined in: [component.ts:800](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L800) Check if this component belongs to a specific group. #### Parameters ##### groupName `string` The name of the group to check. #### Returns `boolean` True if the component is in the specified group. *** ### pin() > **pin**(`number`): [`Pin`](Class.Pin.md) Defined in: [component.ts:770](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L770) Returns a [Pin](Class.Pin.md) object from the component. #### Parameters ##### number The pin number or identifier. `string` | `number` #### Returns [`Pin`](Class.Pin.md) The pin object. --- ## Pin *Class: Pin* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Pin Defined in: [pin.ts:16](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L16) Class representing a pin in a schematic. Pin ## Constructors ### Constructor > **new Pin**(`reference`, `number`, `type?`, `owner?`, `powerInfo?`): `Pin` Defined in: [pin.ts:37](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L37) Initializes a new pin with a given reference, number, and optional type. #### Parameters ##### reference `string` The reference identifier for the pin. ##### number The pin number or identifier. `string` | `number` ##### type? `TPinType` The type of the pin. Defaults to 'passive'. ##### owner? [`Component`](Class.Component.md) The owner component of this pin. ##### powerInfo? [`IPinPowerInfo`](Interface.IPinPowerInfo.md) Power characteristics of the pin. #### Returns `Pin` #### Example ```ts let pin = new Pin('R1', 1, 'input'); let powerPin = new Pin('U1', 5, 'power_in', this, { minimum_voltage: -0.3, maximum_voltage: 6.5, current: 2 }); ``` ## Properties ### number > **number**: `string` \| `number` = `''` Defined in: [pin.ts:17](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L17) *** ### owner > **owner**: `null` \| [`Component`](Class.Component.md) Defined in: [pin.ts:20](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L20) *** ### powerInfo? > `optional` **powerInfo**: [`IPinPowerInfo`](Interface.IPinPowerInfo.md) Defined in: [pin.ts:21](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L21) *** ### reference > **reference**: `string` = `''` Defined in: [pin.ts:18](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L18) *** ### type > **type**: `TPinType` Defined in: [pin.ts:19](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pin.ts#L19) --- ## Power *Class: Power* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / Power Defined in: [buses.ts:68](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L68) ## Constructors ### Constructor > **new Power**(`__namedParameters`): `Power` Defined in: [buses.ts:73](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L73) #### Parameters ##### \_\_namedParameters `IPower` = `{}` #### Returns `Power` ## Properties ### current? > `optional` **current**: `number` Defined in: [buses.ts:72](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L72) *** ### gnd > **gnd**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:70](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L70) *** ### power > **power**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:69](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L69) *** ### voltage? > `optional` **voltage**: `number` Defined in: [buses.ts:71](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L71) --- ## TrackBuilder *Class: TrackBuilder* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / TrackBuilder Defined in: [pcb/pcb\_track\_builder.ts:6](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L6) ## Constructors ### Constructor > **new TrackBuilder**(`pcb`, `options?`): `TrackBuilder` Defined in: [pcb/pcb\_track\_builder.ts:19](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L19) #### Parameters ##### pcb [`PCB`](Class.PCB.md) ##### options? ###### debug? `boolean` ###### deferStaging? `boolean` ###### locked? `boolean` ###### net? `string` #### Returns `TrackBuilder` ## Methods ### from() > **from**(`startPos`, `layer?`, `width?`): `this` Defined in: [pcb/pcb\_track\_builder.ts:27](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L27) #### Parameters ##### startPos ###### x `number` ###### y `number` ##### layer? `string` ##### width? `number` #### Returns `this` *** ### getElements() > **getElements**(): `IGeneratedElement`[] Defined in: [pcb/pcb\_track\_builder.ts:367](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L367) #### Returns `IGeneratedElement`[] *** ### powerInfo() > **powerInfo**(`info`): `this` Defined in: [pcb/pcb\_track\_builder.ts:37](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L37) #### Parameters ##### info `IPowerInfo` #### Returns `this` *** ### to() > **to**(`endPos`): `this` Defined in: [pcb/pcb\_track\_builder.ts:84](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L84) #### Parameters ##### endPos ###### layer? `string` ###### width? `number` ###### x `number` ###### y `number` #### Returns `this` *** ### via() > **via**(`params`): `this` Defined in: [pcb/pcb\_track\_builder.ts:269](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_track_builder.ts#L269) #### Parameters ##### params ###### drill? `number` ###### layers? `string`[] ###### net? `string` ###### powerInfo? `IViaPowerInfo` ###### size? `number` #### Returns `this` --- ## KiCAD *Class: KiCAD* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / KiCAD Defined in: [kicad.ts:12](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L12) ## Constructors ### Constructor > **new KiCAD**(): `KiCAD` Defined in: [kicad.ts:24](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L24) #### Returns `KiCAD` ## Methods ### detectFlatpakInstallation() > **detectFlatpakInstallation**(): `boolean` Defined in: [kicad.ts:83](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L83) Detect if KiCAD is installed via flatpak #### Returns `boolean` *** ### getLibraryPaths() > **getLibraryPaths**(): `object` Defined in: [kicad.ts:118](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L118) Get library paths based on installation type #### Returns `object` ##### footprints > **footprints**: `string` ##### symbols > **symbols**: `string` *** ### isFlatpakInstallation() > **isFlatpakInstallation**(): `boolean` Defined in: [kicad.ts:111](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L111) Check if current installation is flatpak #### Returns `boolean` --- ## I2C *Class: I2C* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / I2C Defined in: [buses.ts:4](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L4) ## Constructors ### Constructor > **new I2C**(`sda`, `scl`): `I2C` Defined in: [buses.ts:7](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L7) #### Parameters ##### sda [`Pin`](Class.Pin.md) ##### scl [`Pin`](Class.Pin.md) #### Returns `I2C` ## Properties ### scl > **scl**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:6](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L6) *** ### sda > **sda**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:5](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L5) --- ## UART *Class: UART* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / UART Defined in: [buses.ts:13](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L13) ## Constructors ### Constructor > **new UART**(`rx`, `tx`, `rts?`, `cts?`): `UART` Defined in: [buses.ts:18](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L18) #### Parameters ##### rx [`Pin`](Class.Pin.md) ##### tx [`Pin`](Class.Pin.md) ##### rts? [`Pin`](Class.Pin.md) ##### cts? [`Pin`](Class.Pin.md) #### Returns `UART` ## Properties ### cts? > `optional` **cts**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:17](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L17) *** ### rts? > `optional` **rts**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:16](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L16) *** ### rx > **rx**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:15](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L15) *** ### tx > **tx**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:14](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L14) --- ## USB *Class: USB* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / USB Defined in: [buses.ts:26](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L26) ## Constructors ### Constructor > **new USB**(`DP`, `DN`): `USB` Defined in: [buses.ts:29](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L29) #### Parameters ##### DP [`Pin`](Class.Pin.md) ##### DN [`Pin`](Class.Pin.md) #### Returns `USB` ## Properties ### dn > **dn**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:28](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L28) *** ### dp > **dp**: [`Pin`](Class.Pin.md) Defined in: [buses.ts:27](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/buses.ts#L27) --- ## IComponent *Interface: IComponent* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IComponent Defined in: [component.ts:21](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L21) ## Properties ### datasheet? > `optional` **datasheet**: `string` Defined in: [component.ts:27](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L27) *** ### description? > `optional` **description**: `string` Defined in: [component.ts:27](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L27) *** ### dnp? > `optional` **dnp**: `boolean` Defined in: [component.ts:28](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L28) *** ### fab? > `optional` **fab**: `ITextPositioning` \| \[`undefined` \| `null` \| `string`, `ITextPositioning`\] Defined in: [component.ts:25](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L25) *** ### footprint? > `optional` **footprint**: `string` Defined in: [component.ts:26](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L26) *** ### mpn? > `optional` **mpn**: `string` Defined in: [component.ts:28](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L28) *** ### pcb? > `optional` **pcb**: `object` Defined in: [component.ts:29](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L29) #### rotation? > `optional` **rotation**: `number` #### side? > `optional` **side**: `"front"` \| `"back"` #### x > **x**: `number` #### y > **y**: `number` *** ### pins? > `optional` **pins**: [`Pin`](Class.Pin.md)[] Defined in: [component.ts:29](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L29) *** ### prefix? > `optional` **prefix**: `string` Defined in: [component.ts:27](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L27) *** ### reference? > `optional` **reference**: `string` \| `ITextPositioning` \| \[`undefined` \| `null` \| `string`, `ITextPositioning`\] Defined in: [component.ts:23](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L23) *** ### sch? > `optional` **sch**: `object` Defined in: [component.ts:30](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L30) #### rotation > **rotation**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### simulation? > `optional` **simulation**: `object` Defined in: [component.ts:30](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L30) #### include > **include**: `boolean` #### model? > `optional` **model**: `string` *** ### sourceInfo? > `optional` **sourceInfo**: `SourceInfo` Defined in: [component.ts:32](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L32) *** ### symbol? > `optional` **symbol**: `string` Defined in: [component.ts:22](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L22) *** ### text? > `optional` **text**: `object`[] Defined in: [component.ts:33](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L33) #### bold? > `optional` **bold**: `boolean` #### fontSize? > `optional` **fontSize**: `number` #### height? > `optional` **height**: `number` #### italic? > `optional` **italic**: `boolean` #### justify? > `optional` **justify**: `object` ##### justify.horizontal? > `optional` **horizontal**: `"center"` \| `"left"` \| `"right"` ##### justify.mirror? > `optional` **mirror**: `boolean` ##### justify.vertical? > `optional` **vertical**: `"top"` \| `"bottom"` \| `"middle"` #### layer? > `optional` **layer**: `string` #### property > **property**: `string` #### rotation? > `optional` **rotation**: `number` #### show? > `optional` **show**: `boolean` #### text > **text**: `string` #### thickness? > `optional` **thickness**: `number` #### width? > `optional` **width**: `number` #### x > **x**: `number` #### y > **y**: `number` *** ### uuid? > `optional` **uuid**: `string` Defined in: [component.ts:28](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L28) *** ### value? > `optional` **value**: `string` \| `ITextPositioning` \| \[`string`, `ITextPositioning`\] Defined in: [component.ts:24](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L24) *** ### via? > `optional` **via**: `boolean` Defined in: [component.ts:29](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L29) *** ### viaData? > `optional` **viaData**: `IVia` Defined in: [component.ts:31](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L31) *** ### voltage? > `optional` **voltage**: `string` Defined in: [component.ts:27](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L27) *** ### wattage? > `optional` **wattage**: `string` Defined in: [component.ts:28](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/component.ts#L28) --- ## IPinPowerInfo *Interface: IPinPowerInfo* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IPinPowerInfo Defined in: [pcb/pcb\_interfaces.ts:134](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L134) ## Properties ### current? > `optional` **current**: `number` Defined in: [pcb/pcb\_interfaces.ts:137](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L137) *** ### maximum\_voltage? > `optional` **maximum\_voltage**: `number` Defined in: [pcb/pcb\_interfaces.ts:136](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L136) *** ### minimum\_voltage? > `optional` **minimum\_voltage**: `number` Defined in: [pcb/pcb\_interfaces.ts:135](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L135) --- ## kicad_path *Variable: kicad\_path* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / kicad\_path > **kicad\_path**: `string` \| `undefined` Defined in: [kicad.ts:8](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L8) --- ## kicad_cli_path *Variable: kicad\_cli\_path* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / kicad\_cli\_path > **kicad\_cli\_path**: `string` \| `undefined` Defined in: [kicad.ts:9](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L9) --- ## DebugVisualizer *Class: DebugVisualizer* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / DebugVisualizer Defined in: [routing/utils/debug\_visualizer.ts:26](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/utils/debug_visualizer.ts#L26) Generates debug visualizations of routing grids and paths. Creates simple PPM (Portable PixMap) images that can be viewed with most image viewers. ## Constructors ### Constructor > **new DebugVisualizer**(): `DebugVisualizer` #### Returns `DebugVisualizer` ## Methods ### visualizeAllLayers() > `static` **visualizeAllLayers**(`grid`, `obstacles`, `paths`, `filename`, `cellSize`, `steinerPoints?`, `debug?`): `void` Defined in: [routing/utils/debug\_visualizer.ts:483](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/utils/debug_visualizer.ts#L483) Visualize multiple layers side by side. #### Parameters ##### grid [`RoutingGrid`](Class.RoutingGrid.md) The routing grid ##### obstacles [`IRoutingObstacle`](Interface.IRoutingObstacle.md)[] Array of obstacles ##### paths `IRoutePath`[] Array of routed paths ##### filename `string` = `'routing_debug_all_layers'` Output filename (without extension) ##### cellSize `number` = `2` Pixels per grid cell (default: 2) ##### steinerPoints? `ISteinerPoint`[] ##### debug? `boolean` = `false` #### Returns `void` *** ### visualizeRouting() > `static` **visualizeRouting**(`grid`, `obstacles`, `paths`, `filename`, `layer?`, `cellSize?`, `steinerPoints?`, `debug?`): `void` Defined in: [routing/utils/debug\_visualizer.ts:43](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/utils/debug_visualizer.ts#L43) Generate a debug visualization of the routing grid with obstacles and paths. #### Parameters ##### grid [`RoutingGrid`](Class.RoutingGrid.md) The routing grid ##### obstacles [`IRoutingObstacle`](Interface.IRoutingObstacle.md)[] Array of obstacles ##### paths `IRoutePath`[] Array of routed paths ##### filename `string` = `'routing_debug'` Output filename (without extension) ##### layer? `string` Which layer to visualize (default: first layer in grid) ##### cellSize? `number` = `1` Pixels per grid cell (default: 1, max 2 for large grids) ##### steinerPoints? `ISteinerPoint`[] Optional Steiner points to highlight ##### debug? `boolean` = `false` #### Returns `void` #### Example ```ts DebugVisualizer.visualizeRouting(grid, obstacles, [path], 'debug_route', 'F.Cu', 1); ``` --- ## ObstacleBuilder *Class: ObstacleBuilder* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / ObstacleBuilder Defined in: [routing/shared/obstacle\_builder.ts:16](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L16) Builds routing obstacles from PCB elements. Converts components, pads, zones, and other PCB features into obstacle representations for the routing grid. ## Constructors ### Constructor > **new ObstacleBuilder**(): `ObstacleBuilder` #### Returns `ObstacleBuilder` ## Methods ### buildFromComponent() > `static` **buildFromComponent**(`component`, `clearance`): `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Defined in: [routing/shared/obstacle\_builder.ts:203](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L203) Build an obstacle from a component's body (courtyard). #### Parameters ##### component [`Component`](Class.Component.md) The component ##### clearance `number` Clearance around component in mm #### Returns `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Component body obstacle, or null if unable to determine bounds *** ### buildFromComponentPads() > `static` **buildFromComponentPads**(`component`, `clearance`, `pcb`, `debug`): [`IRoutingObstacle`](Interface.IRoutingObstacle.md)[] Defined in: [routing/shared/obstacle\_builder.ts:242](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L242) Build obstacles from a component's pads. #### Parameters ##### component [`Component`](Class.Component.md) The component ##### clearance `number` Clearance around pads in mm ##### pcb [`PCB`](Class.PCB.md) PCB instance to resolve nets ##### debug `boolean` = `false` #### Returns [`IRoutingObstacle`](Interface.IRoutingObstacle.md)[] Array of pad obstacles *** ### buildFromKeepoutZone() > `static` **buildFromKeepoutZone**(`zone`): `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Defined in: [routing/shared/obstacle\_builder.ts:388](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L388) Build an obstacle from a keepout zone. #### Parameters ##### zone `IKeepoutZone` The keepout zone #### Returns `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Keepout obstacle, or null if tracks are allowed *** ### buildFromOutline() > `static` **buildFromOutline**(`outline`, `clearance`): `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Defined in: [routing/shared/obstacle\_builder.ts:497](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L497) Build an obstacle from a board outline. #### Parameters ##### outline `IOutline` The board outline ##### clearance `number` Clearance from outline in mm #### Returns `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Outline obstacle (everything outside the outline is blocked) *** ### buildFromPCB() > `static` **buildFromPCB**(`pcb`, `defaultClearance`, `additionalComponents?`, `debug?`): [`IRoutingObstacle`](Interface.IRoutingObstacle.md)[] Defined in: [routing/shared/obstacle\_builder.ts:31](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L31) Build all obstacles from a PCB instance. #### Parameters ##### pcb [`PCB`](Class.PCB.md) The PCB to extract obstacles from ##### defaultClearance `number` = `0.2` Default clearance for obstacles in mm ##### additionalComponents? [`Component`](Class.Component.md)[] Additional components to include (e.g., from pins being routed) ##### debug? `boolean` = `false` #### Returns [`IRoutingObstacle`](Interface.IRoutingObstacle.md)[] Array of routing obstacles #### Example ```ts const obstacles = ObstacleBuilder.buildFromPCB(pcb, 0.2); obstacles.forEach(obs => grid.addObstacle(obs)); ``` *** ### buildFromTrack() > `static` **buildFromTrack**(`track`, `width`, `clearance`, `net?`, `isManualRoute?`): [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Defined in: [routing/shared/obstacle\_builder.ts:419](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L419) Build an obstacle from a track. #### Parameters ##### track `IGrLine` The track (IGrLine) ##### width `number` Track width in mm ##### clearance `number` Clearance around track in mm ##### net? `string` Net name for net-aware routing (optional) ##### isManualRoute? `boolean` #### Returns [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Track obstacle *** ### buildFromZone() > `static` **buildFromZone**(`zone`): `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Defined in: [routing/shared/obstacle\_builder.ts:363](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/obstacle_builder.ts#L363) Build an obstacle from a filled zone. #### Parameters ##### zone `IFilledZone` The filled zone #### Returns `null` \| [`IRoutingObstacle`](Interface.IRoutingObstacle.md) Zone obstacle, or null if invalid --- ## PadResolver *Class: PadResolver* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / PadResolver Defined in: [routing/shared/pad\_resolver.ts:47](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L47) Resolves pin objects to their physical pad positions on the PCB. Handles coordinate transformation from footprint-relative to board-absolute coordinates. ## Constructors ### Constructor > **new PadResolver**(): `PadResolver` #### Returns `PadResolver` ## Methods ### getAllPadGeometries() > `static` **getAllPadGeometries**(`component`): [`IPadGeometry`](Interface.IPadGeometry.md)[] Defined in: [routing/shared/pad\_resolver.ts:339](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L339) Get all pad geometries for a component. Useful for obstacle detection and collision checking. #### Parameters ##### component [`Component`](Class.Component.md) The component to get pads from #### Returns [`IPadGeometry`](Interface.IPadGeometry.md)[] Array of pad geometries *** ### getPadCenter() > `static` **getPadCenter**(`pin`): `null` \| \{ `layer`: `string`; `x`: `number`; `y`: `number`; \} Defined in: [routing/shared/pad\_resolver.ts:62](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L62) Get the absolute center position of a pin's pad on the PCB. #### Parameters ##### pin [`Pin`](Class.Pin.md) The pin to resolve #### Returns `null` \| \{ `layer`: `string`; `x`: `number`; `y`: `number`; \} The absolute X,Y coordinates in mm, or null if unable to resolve #### Example ```ts const center = PadResolver.getPadCenter(resistor.pin(1)); if (center) { console.log(`Pad is at ${center.x}, ${center.y}`); } ``` *** ### getPadGeometry() > `static` **getPadGeometry**(`component`, `pinNumber`): `null` \| [`IPadGeometry`](Interface.IPadGeometry.md) Defined in: [routing/shared/pad\_resolver.ts:95](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L95) Get complete geometry information for a specific pad. #### Parameters ##### component [`Component`](Class.Component.md) The component containing the pad ##### pinNumber The pin/pad number to look up `string` | `number` #### Returns `null` \| [`IPadGeometry`](Interface.IPadGeometry.md) Complete pad geometry, or null if not found #### Example ```ts const padGeom = PadResolver.getPadGeometry(resistor, 1); if (padGeom) { console.log(`Pad shape: ${padGeom.shape}, size: ${padGeom.size.width}x${padGeom.size.height}mm`); } ``` --- ## RoutingGrid *Class: RoutingGrid* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / RoutingGrid Defined in: [routing/shared/routing\_grid.ts:132](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L132) Grid-based spatial representation for PCB routing. Discretizes continuous PCB space into a uniform grid for pathfinding algorithms. ## Constructors ### Constructor > **new RoutingGrid**(`bounds`, `gridResolution`, `layers`, `debug`): `RoutingGrid` Defined in: [routing/shared/routing\_grid.ts:159](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L159) Creates a new routing grid. #### Parameters ##### bounds World-space bounds of the routing area in mm ###### maxX `number` ###### maxY `number` ###### minX `number` ###### minY `number` ##### gridResolution `number` Size of each grid cell in mm (e.g., 0.1 = 10 cells per mm) ##### layers `string`[] List of copper layers to route on (e.g., ['F.Cu', 'B.Cu']) ##### debug `boolean` = `false` #### Returns `RoutingGrid` #### Example ```ts const grid = new RoutingGrid( { minX: 0, maxX: 100, minY: 0, maxY: 80 }, 0.1, // 0.1mm per cell ['F.Cu', 'B.Cu'] ); ``` ## Methods ### addObstacle() > **addObstacle**(`obstacle`): `void` Defined in: [routing/shared/routing\_grid.ts:190](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L190) Add an obstacle to the grid. Marks all cells within the obstacle bounds as occupied. Note: Clearance is NOT applied here - it's checked during routing in isOccupied(). #### Parameters ##### obstacle [`IRoutingObstacle`](Interface.IRoutingObstacle.md) The obstacle to add #### Returns `void` *** ### checkTrackObstaclePrecise() > **checkTrackObstaclePrecise**(`worldX`, `worldY`, `layer`, `clearance`, `net?`): `boolean` Defined in: [routing/shared/routing\_grid.ts:788](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L788) Check if a position conflicts with track obstacles using precise point-to-segment distance. This method provides more accurate clearance checking for angled tracks. #### Parameters ##### worldX `number` World X coordinate in mm ##### worldY `number` World Y coordinate in mm ##### layer `string` Layer to check ##### clearance `number` Required clearance in mm ##### net? `string` Net we're routing (for same-net exemptions) #### Returns `boolean` True if position conflicts with track obstacles *** ### clear() > **clear**(): `void` Defined in: [routing/shared/routing\_grid.ts:1070](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1070) Clear all obstacles from the grid. Useful for rebuilding the grid with different obstacles. #### Returns `void` *** ### getBounds() > **getBounds**(): `object` Defined in: [routing/shared/routing\_grid.ts:1062](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1062) Get grid bounds in world coordinates. #### Returns `object` ##### maxX > **maxX**: `number` ##### maxY > **maxY**: `number` ##### minX > **minX**: `number` ##### minY > **minY**: `number` *** ### getCell() > **getCell**(`x`, `y`, `layer`): `undefined` \| [`IGridCell`](Interface.IGridCell.md) Defined in: [routing/shared/routing\_grid.ts:1008](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1008) Get a cell by coordinates, if present. #### Parameters ##### x `number` ##### y `number` ##### layer `string` #### Returns `undefined` \| [`IGridCell`](Interface.IGridCell.md) *** ### getCellCost() > **getCellCost**(`x`, `y`, `layer`): `number` Defined in: [routing/shared/routing\_grid.ts:924](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L924) Get the routing cost for a grid cell. #### Parameters ##### x `number` Grid X coordinate ##### y `number` Grid Y coordinate ##### layer `string` Layer to check #### Returns `number` Cost multiplier (1.0 = normal, higher = more expensive) *** ### getDimensions() > **getDimensions**(): `object` Defined in: [routing/shared/routing\_grid.ts:1037](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1037) Get grid dimensions. #### Returns `object` ##### height > **height**: `number` ##### layers > **layers**: `number` ##### width > **width**: `number` *** ### getLayers() > **getLayers**(): `string`[] Defined in: [routing/shared/routing\_grid.ts:1055](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1055) Get the list of layers in the grid. #### Returns `string`[] *** ### getResolution() > **getResolution**(): `number` Defined in: [routing/shared/routing\_grid.ts:1048](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1048) Get grid resolution in mm. #### Returns `number` *** ### getStats() > **getStats**(): `object` Defined in: [routing/shared/routing\_grid.ts:1082](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L1082) Get statistics about the grid. #### Returns `object` ##### freeCells > **freeCells**: `number` ##### occupancyPercent > **occupancyPercent**: `number` ##### occupiedCells > **occupiedCells**: `number` ##### totalCells > **totalCells**: `number` *** ### getWorldXFromGrid() > **getWorldXFromGrid**(`gridX`): `number` Defined in: [routing/shared/routing\_grid.ts:863](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L863) Convert grid X coordinate to world X coordinate using cell boundary (no center offset). This provides more accurate positioning for track creation. #### Parameters ##### gridX `number` Grid X coordinate #### Returns `number` World X coordinate in mm *** ### getWorldYFromGrid() > **getWorldYFromGrid**(`gridY`): `number` Defined in: [routing/shared/routing\_grid.ts:873](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L873) Convert grid Y coordinate to world Y coordinate using cell boundary (no center offset). This provides more accurate positioning for track creation. #### Parameters ##### gridY `number` Grid Y coordinate #### Returns `number` World Y coordinate in mm *** ### gridToWorld() > **gridToWorld**(`gridX`, `gridY`): `object` Defined in: [routing/shared/routing\_grid.ts:979](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L979) Convert grid coordinates to world coordinates (mm). Returns the center of the grid cell. #### Parameters ##### gridX `number` Grid X coordinate ##### gridY `number` Grid Y coordinate #### Returns `object` World coordinates in mm ##### x > **x**: `number` ##### y > **y**: `number` *** ### gridToWorldX() > **gridToWorldX**(`gridX`): `number` Defined in: [routing/shared/routing\_grid.ts:844](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L844) Convert grid X coordinate to world X coordinate in mm. #### Parameters ##### gridX `number` Grid X coordinate #### Returns `number` World X coordinate in mm *** ### gridToWorldY() > **gridToWorldY**(`gridY`): `number` Defined in: [routing/shared/routing\_grid.ts:853](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L853) Convert grid Y coordinate to world Y coordinate in mm. #### Parameters ##### gridY `number` Grid Y coordinate #### Returns `number` World Y coordinate in mm *** ### hasPadWithinClearance() > **hasPadWithinClearance**(`x`, `y`, `layer`, `clearanceMm`): `boolean` Defined in: [routing/shared/routing\_grid.ts:663](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L663) Check if any pad lies within the specified clearance of a grid coordinate. Ignores net assignments so that callers can enforce absolute pad spacing. #### Parameters ##### x `number` ##### y `number` ##### layer `string` ##### clearanceMm `number` #### Returns `boolean` *** ### isInBounds() > **isInBounds**(`x`, `y`): `boolean` Defined in: [routing/shared/routing\_grid.ts:993](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L993) Check if grid coordinates are within bounds. #### Parameters ##### x `number` Grid X coordinate ##### y `number` Grid Y coordinate #### Returns `boolean` True if in bounds *** ### isOccupied() > **isOccupied**(`x`, `y`, `layer`, `clearance`, `net?`, `considerObstacleClearance?`, `sumObstacleClearance?`): `boolean` Defined in: [routing/shared/routing\_grid.ts:703](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L703) Check if a grid cell is occupied. #### Parameters ##### x `number` Grid X coordinate ##### y `number` Grid Y coordinate ##### layer `string` Layer to check ##### clearance `number` = `0` Additional clearance to check (in mm, not grid cells) ##### net? `string` Net we're routing - obstacles on same net don't block ##### considerObstacleClearance? `boolean` = `false` ##### sumObstacleClearance? `boolean` = `false` #### Returns `boolean` True if occupied, false if available for routing *** ### isPadCell() > **isPadCell**(`x`, `y`, `layer`): `boolean` Defined in: [routing/shared/routing\_grid.ts:653](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L653) Check if a specific grid cell belongs to a pad area on a given layer. #### Parameters ##### x `number` ##### y `number` ##### layer `string` #### Returns `boolean` *** ### setCellCost() > **setCellCost**(`x`, `y`, `layer`, `cost`): `void` Defined in: [routing/shared/routing\_grid.ts:939](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L939) Set the routing cost for a grid cell. Useful for biasing routes toward or away from certain areas. #### Parameters ##### x `number` Grid X coordinate ##### y `number` Grid Y coordinate ##### layer `string` Layer ##### cost `number` Cost multiplier #### Returns `void` *** ### worldToGrid() > **worldToGrid**(`worldX`, `worldY`): `object` Defined in: [routing/shared/routing\_grid.ts:964](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L964) Convert world coordinates (mm) to grid coordinates. #### Parameters ##### worldX `number` X coordinate in mm ##### worldY `number` Y coordinate in mm #### Returns `object` Grid coordinates ##### x > **x**: `number` ##### y > **y**: `number` --- ## Enumeration.RoutingAlgorithm *Enumeration: RoutingAlgorithm* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / RoutingAlgorithm Defined in: [routing/router\_registry.ts:59](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/router_registry.ts#L59) Available routing algorithm identifiers. Use in IAutorouteOptions.algorithm for strong typing and IDE hints. ## Enumeration Members ### AStar > **AStar**: `"astar"` Defined in: [routing/router\_registry.ts:61](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/router_registry.ts#L61) Default plugin-provided autorouter (e.g., @typecad-astar). --- ## Function.executeKiCADCommand *Function: executeKiCADCommand()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / executeKiCADCommand > **executeKiCADCommand**(`command`, `args`, `options`): `Promise`\ Defined in: [kicad\_commands.ts:16](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L16) Execute a KiCAD command with automatic flatpak wrapper detection ## Parameters ### command `string` ### args `string`[] = `[]` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `Promise`\ --- ## Function.executeKiCADCommandSync *Function: executeKiCADCommandSync()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / executeKiCADCommandSync > **executeKiCADCommandSync**(`command`, `args`, `options`): `string` Defined in: [kicad\_commands.ts:46](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L46) Execute a KiCAD command synchronously ## Parameters ### command `string` ### args `string`[] = `[]` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `string` --- ## Function.exportPCB *Function: exportPCB()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / exportPCB > **exportPCB**(`pcbPath`, `outputPath`, `format`, `options`): `Promise`\ Defined in: [kicad\_commands.ts:104](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L104) Export PCB to various formats ## Parameters ### pcbPath `string` ### outputPath `string` ### format `"gerber"` | `"svg"` | `"pdf"` | `"step"` | `"dxf"` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `Promise`\ --- ## Function.exportSchematic *Function: exportSchematic()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / exportSchematic > **exportSchematic**(`schPath`, `outputPath`, `format`, `options`): `Promise`\ Defined in: [kicad\_commands.ts:117](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L117) Export schematic to various formats ## Parameters ### schPath `string` ### outputPath `string` ### format `"svg"` | `"pdf"` | `"netlist"` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `Promise`\ --- ## Function.runDRC *Function: runDRC()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / runDRC > **runDRC**(`pcbPath`, `options`): `Promise`\ Defined in: [kicad\_commands.ts:90](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L90) Run Design Rule Check on a PCB file ## Parameters ### pcbPath `string` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `Promise`\ --- ## Function.runERC *Function: runERC()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / runERC > **runERC**(`schPath`, `options`): `Promise`\ Defined in: [kicad\_commands.ts:102](https://github.com/typecad/typecad/blob/main/kicad_commands.ts#L102) Run Electrical Rule Check on a schematic file ## Parameters ### schPath `string` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `Promise`\ --- ## Function.upgradeFootprint *Function: upgradeFootprint()* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / upgradeFootprint > **upgradeFootprint**(`footprintPath`, `options`): `Promise`\ Defined in: [kicad\_commands.ts:97](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L97) Upgrade a footprint file to the latest format ## Parameters ### footprintPath `string` ### options [`KiCADCommandOptions`](Interface.KiCADCommandOptions.md) = `{}` ## Returns `Promise`\ --- ## IConnectionIdentifier *Interface: IConnectionIdentifier* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IConnectionIdentifier Defined in: [pcb/pcb\_interfaces.ts:315](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L315) Identifier for a specific connection between two pins. Used to exclude connections from autorouting or to specify manual routes. ## Properties ### from > **from**: [`Pin`](Class.Pin.md) Defined in: [pcb/pcb\_interfaces.ts:317](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L317) Source pin *** ### to > **to**: [`Pin`](Class.Pin.md) Defined in: [pcb/pcb\_interfaces.ts:319](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L319) Destination pin --- ## IGridCell *Interface: IGridCell* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IGridCell Defined in: [routing/shared/routing\_grid.ts:40](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L40) Represents a single cell in the routing grid. ## Properties ### absoluteBlock? > `optional` **absoluteBlock**: `boolean` Defined in: [routing/shared/routing\_grid.ts:60](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L60) If true, this cell blocks routing for all nets (e.g., keepouts, board outline) *** ### clearance? > `optional` **clearance**: `number` Defined in: [routing/shared/routing\_grid.ts:69](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L69) Maximum obstacle-required clearance (mm) affecting this cell *** ### cost > **cost**: `number` Defined in: [routing/shared/routing\_grid.ts:66](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L66) Cost multiplier for routing through this cell (1.0 = normal, higher = discouraged) *** ### isManualRoute? > `optional` **isManualRoute**: `boolean` Defined in: [routing/shared/routing\_grid.ts:57](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L57) If true, this cell is from a manual route and blocks routing even on the same net *** ### layer > **layer**: `string` Defined in: [routing/shared/routing\_grid.ts:48](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L48) Layer this cell is on *** ### net? > `optional` **net**: `string` Defined in: [routing/shared/routing\_grid.ts:54](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L54) If occupied, which net owns this cell (null if not net-specific) *** ### obstacleHalfWidthMm? > `optional` **obstacleHalfWidthMm**: `number` Defined in: [routing/shared/routing\_grid.ts:76](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L76) For track obstacles, the half width (mm) of the occupying geometry. Used to enforce edge-to-edge clearance by requiring the new centerline to stay at least (obstacleHalfWidth + centerlineClearance) away. *** ### obstacleIds? > `optional` **obstacleIds**: `string`[] Defined in: [routing/shared/routing\_grid.ts:79](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L79) IDs of obstacles occupying this cell for precise geometry lookups *** ### occupied > **occupied**: `boolean` Defined in: [routing/shared/routing\_grid.ts:51](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L51) Whether this cell is blocked by an obstacle *** ### pad? > `optional` **pad**: `boolean` Defined in: [routing/shared/routing\_grid.ts:63](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L63) If true, this cell belongs to a pad area (for via placement rules) *** ### x > **x**: `number` Defined in: [routing/shared/routing\_grid.ts:42](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L42) Grid column index *** ### y > **y**: `number` Defined in: [routing/shared/routing\_grid.ts:45](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L45) Grid row index --- ## IManualRoute *Interface: IManualRoute* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IManualRoute Defined in: [pcb/pcb\_interfaces.ts:326](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L326) Pre-specified manual route for a specific connection. When provided, the autorouter will use this exact path instead of calculating one. ## Properties ### from? > `optional` **from**: [`Pin`](Class.Pin.md) Defined in: [pcb/pcb\_interfaces.ts:331](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L331) Source pin (optional if can be inferred from route endpoints and net pins) If not provided, will attempt to match route start position to a pin in the net *** ### route > **route**: `IRoutePath` \| `IAutorouteResult` Defined in: [pcb/pcb\_interfaces.ts:346](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L346) The pre-defined route to use for this connection. Can be: - An IRoutePath object (low-level path with nodes) - An IAutorouteResult from a previous autoroute() or route() call (will use the first route's path) *** ### to? > `optional` **to**: [`Pin`](Class.Pin.md) Defined in: [pcb/pcb\_interfaces.ts:337](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/pcb/pcb_interfaces.ts#L337) Destination pin (optional if can be inferred from route endpoints and net pins) If not provided, will attempt to match route end position to a pin in the net --- ## IPadGeometry *Interface: IPadGeometry* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IPadGeometry Defined in: [routing/shared/pad\_resolver.ts:11](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L11) Geometry information for a component pad on the PCB. ## Properties ### center > **center**: `object` Defined in: [routing/shared/pad\_resolver.ts:13](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L13) Absolute center position on the PCB in mm #### x > **x**: `number` #### y > **y**: `number` *** ### componentRef? > `optional` **componentRef**: `string` Defined in: [routing/shared/pad\_resolver.ts:40](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L40) Component reference (for debugging) *** ### layer > **layer**: `string` Defined in: [routing/shared/pad\_resolver.ts:28](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L28) Layer the pad is on (e.g., 'F.Cu', 'B.Cu'). For through-hole pads, this is the primary layer but the pad exists on all layers *** ### layers > **layers**: `string`[] Defined in: [routing/shared/pad\_resolver.ts:31](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L31) All layers this pad exists on (for through-hole pads, includes all copper layers) *** ### net? > `optional` **net**: `string` Defined in: [routing/shared/pad\_resolver.ts:37](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L37) Net name this pad belongs to (for net-aware routing) *** ### number > **number**: `string` \| `number` Defined in: [routing/shared/pad\_resolver.ts:34](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L34) Pad number/name *** ### rotation > **rotation**: `number` Defined in: [routing/shared/pad\_resolver.ts:25](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L25) Absolute rotation in degrees *** ### shape > **shape**: `"circle"` \| `"rect"` \| `"oval"` \| `"roundrect"` \| `"custom"` Defined in: [routing/shared/pad\_resolver.ts:16](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L16) Pad shape type *** ### size > **size**: `object` Defined in: [routing/shared/pad\_resolver.ts:22](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L22) Pad size in mm #### height > **height**: `number` #### width > **width**: `number` *** ### type > **type**: `"smd"` \| `"thru_hole"` \| `"np_thru_hole"` \| `"connect"` Defined in: [routing/shared/pad\_resolver.ts:19](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/pad_resolver.ts#L19) Pad type (SMD or through-hole) --- ## IRoutingEngine *Interface: IRoutingEngine* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IRoutingEngine Defined in: [routing/router\_registry.ts:12](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/router_registry.ts#L12) Common routing engine interface implemented by all algorithms. Allows PCB to invoke a selected router without coupling to its implementation. ## Methods ### route() > **route**(`start`, `end`, `directives?`): `IRoutePath` Defined in: [routing/router\_registry.ts:17](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/router_registry.ts#L17) Compute a route from start to end, optionally passing through waypoints. Coordinates are in world space (mm), with an explicit layer at each point. #### Parameters ##### start ###### layer `string` ###### x `number` ###### y `number` ##### end ###### layer `string` ###### x `number` ###### y `number` ##### directives? `IRouteDirectives` | `IAutorouteWaypoint`[] #### Returns `IRoutePath` --- ## IRoutingObstacle *Interface: IRoutingObstacle* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / IRoutingObstacle Defined in: [routing/shared/routing\_grid.ts:85](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L85) Represents an obstacle in the routing space. ## Properties ### bounds > **bounds**: `object` Defined in: [routing/shared/routing\_grid.ts:90](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L90) Bounding box in world coordinates (mm) #### maxX > **maxX**: `number` #### maxY > **maxY**: `number` #### minX > **minX**: `number` #### minY > **minY**: `number` *** ### clearance > **clearance**: `number` Defined in: [routing/shared/routing\_grid.ts:104](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L104) Required clearance around this obstacle in mm *** ### isManualRoute? > `optional` **isManualRoute**: `boolean` Defined in: [routing/shared/routing\_grid.ts:110](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L110) If true, this obstacle blocks routing even on the same net (for manual routes) *** ### layers > **layers**: `string`[] Defined in: [routing/shared/routing\_grid.ts:98](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L98) Layers this obstacle exists on *** ### net? > `optional` **net**: `string` Defined in: [routing/shared/routing\_grid.ts:101](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L101) Net assignment - obstacles on same net don't block each other *** ### padShape? > `optional` **padShape**: `object` Defined in: [routing/shared/routing\_grid.ts:116](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L116) Optional pad geometry for precise rasterization #### center > **center**: `object` ##### center.x > **x**: `number` ##### center.y > **y**: `number` #### height > **height**: `number` #### rotation > **rotation**: `number` #### shape > **shape**: `"circle"` \| `"rect"` \| `"oval"` \| `"roundrect"` #### width > **width**: `number` *** ### polygon? > `optional` **polygon**: `object` Defined in: [routing/shared/routing\_grid.ts:125](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L125) Optional polygon geometry (zones, keepouts) for precise rasterization #### points > **points**: `object`[] *** ### priority? > `optional` **priority**: `number` Defined in: [routing/shared/routing\_grid.ts:107](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L107) Priority - higher priority obstacles block lower priority ones *** ### segment? > `optional` **segment**: `object` Defined in: [routing/shared/routing\_grid.ts:113](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L113) Optional geometric description for precise rasterization (used for tracks) #### width > **width**: `number` #### x1 > **x1**: `number` #### x2 > **x2**: `number` #### y1 > **y1**: `number` #### y2 > **y2**: `number` *** ### type > **type**: `"component"` \| `"pad"` \| `"track"` \| `"zone"` \| `"keepout"` \| `"outline"` Defined in: [routing/shared/routing\_grid.ts:87](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/routing/shared/routing_grid.ts#L87) Type of obstacle for debugging/visualization --- ## KiCADCommandOptions *Interface: KiCADCommandOptions* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / KiCADCommandOptions Defined in: [kicad\_commands.ts:7](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L7) ## Properties ### cwd? > `optional` **cwd**: `string` Defined in: [kicad\_commands.ts:8](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L8) *** ### stdio? > `optional` **stdio**: `"ignore"` \| `"pipe"` \| `"inherit"` Defined in: [kicad\_commands.ts:9](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L9) *** ### timeout? > `optional` **timeout**: `number` Defined in: [kicad\_commands.ts:10](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad_commands.ts#L10) --- ## is_flatpak *Variable: is\_flatpak* [**@typecad/typecad**](README.md) *** [@typecad/typecad](globals.md) / is\_flatpak > **is\_flatpak**: `boolean` = `false` Defined in: [kicad.ts:10](https://github.com/typecad/typecad/blob/6bbcc8ae1b7d95ad4656019e0545a2a6bf8c25eb/kicad.ts#L10)