altium-to-circuit-json 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tscircuit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # altium-to-circuit-json
2
+
3
+ Convert Altium schematic and PCB documents into [Circuit JSON](https://github.com/tscircuit/circuit-json).
4
+
5
+ The converter is built on [altiumts](https://github.com/tscircuit/altiumts). Its visual tests render the original document with `altiumts` on the left and the converted Circuit JSON with `circuit-to-svg` on the right, then combine the panels with `stack-svgs` and verify them with `bun-match-svg`.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ bun add altium-to-circuit-json
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Automatic format detection accepts text, `Uint8Array`, or `ArrayBuffer` input:
16
+
17
+ ```ts
18
+ import { readFile } from "node:fs/promises"
19
+ import { convertAltiumToCircuitJson } from "altium-to-circuit-json"
20
+
21
+ const bytes = await readFile("motor-controller.PcbDoc")
22
+ const circuitJson = convertAltiumToCircuitJson(bytes)
23
+ ```
24
+
25
+ Parsed `altiumts` documents can be converted directly:
26
+
27
+ ```ts
28
+ import { parseAltiumSchDoc } from "altiumts"
29
+ import { convertAltiumSchDocToCircuitJson } from "altium-to-circuit-json"
30
+
31
+ const document = parseAltiumSchDoc(schematicBytes)
32
+ const circuitJson = convertAltiumSchDocToCircuitJson(document)
33
+ ```
34
+
35
+ The public conversion functions are:
36
+
37
+ - `convertAltiumToCircuitJson(source, options)` for automatic parsing and conversion.
38
+ - `convertAltiumDocumentToCircuitJson(document, options)` for an already parsed document.
39
+ - `convertAltiumPcbDocToCircuitJson(document, options)` for PCB documents.
40
+ - `convertAltiumSchDocToCircuitJson(document, options)` for schematic documents.
41
+
42
+ ## Current coverage
43
+
44
+ PCB conversion currently emits:
45
+
46
+ - polygon board outlines and board cutouts;
47
+ - PCB component placement bounds;
48
+ - top, bottom, and inner-layer copper tracks;
49
+ - vias;
50
+ - circular, rectangular, rounded, octagonal, rotated, pill, slotted, plated, and non-plated pads/holes;
51
+ - top and bottom silkscreen lines, arcs, fills, and text; and
52
+ - Altium mil coordinates converted to millimeters.
53
+
54
+ Schematic conversion currently emits:
55
+
56
+ - sheet identity and border geometry;
57
+ - wires as schematic traces;
58
+ - polylines, polygons, rectangles, circles, ellipses, and arcs;
59
+ - pins, junctions, no-ERC markers, ports, and power ports;
60
+ - labels, net labels, designators, parameters, and text frames; and
61
+ - active multipart/display-mode filtering plus Altium text orientation and anchoring.
62
+
63
+ The package is intentionally an incremental converter. Connectivity source elements, complete component semantics, copper pours/regions, mechanical/dimension primitives, models, and project-level hierarchy remain follow-up areas.
64
+
65
+ ## Visual tests
66
+
67
+ Download the checksum-pinned open-source reference files and run the tests:
68
+
69
+ ```sh
70
+ bun run test
71
+ ```
72
+
73
+ Update the SVG snapshots after an intentional visual change:
74
+
75
+ ```sh
76
+ bun run test:update-svg
77
+ ```
78
+
79
+ Every imported reference used by the test suite has a side-by-side SVG snapshot. The committed fixtures are generated from pinned upstream URLs and are not stored in this repository.
80
+
81
+ ## Development
82
+
83
+ ```sh
84
+ bun install
85
+ bun run typecheck
86
+ bun run format:check
87
+ bun run build
88
+ ```
@@ -0,0 +1,33 @@
1
+ import { AltiumPcbDocument, AltiumSchDoc } from 'altiumts';
2
+ import { AnyCircuitElement } from 'circuit-json';
3
+
4
+ interface ConvertAltiumPcbDocOptions {
5
+ includeBoardOutline?: boolean;
6
+ includeComponents?: boolean;
7
+ includePads?: boolean;
8
+ includeSilkscreen?: boolean;
9
+ includeTraces?: boolean;
10
+ includeVias?: boolean;
11
+ }
12
+ declare function convertAltiumPcbDocToCircuitJson(document: AltiumPcbDocument, options?: ConvertAltiumPcbDocOptions): AnyCircuitElement[];
13
+
14
+ interface ConvertAltiumSchDocOptions {
15
+ includeHidden?: boolean;
16
+ includeSheetBorder?: boolean;
17
+ includeText?: boolean;
18
+ schematicUnitScale?: number;
19
+ sheetName?: string;
20
+ }
21
+ declare function convertAltiumSchDocToCircuitJson(document: AltiumSchDoc, options?: ConvertAltiumSchDocOptions): AnyCircuitElement[];
22
+
23
+ type AltiumSourceType = "auto" | "pcb" | "schematic";
24
+ interface ConvertAltiumToCircuitJsonOptions {
25
+ pcb?: ConvertAltiumPcbDocOptions;
26
+ schematic?: ConvertAltiumSchDocOptions;
27
+ sourceType?: AltiumSourceType;
28
+ }
29
+ type SupportedAltiumDocument = AltiumPcbDocument | AltiumSchDoc;
30
+ declare function convertAltiumToCircuitJson(source: ArrayBuffer | Uint8Array | string, options?: ConvertAltiumToCircuitJsonOptions): AnyCircuitElement[];
31
+ declare function convertAltiumDocumentToCircuitJson(document: unknown, options?: ConvertAltiumToCircuitJsonOptions): AnyCircuitElement[];
32
+
33
+ export { type AltiumSourceType, type ConvertAltiumPcbDocOptions, type ConvertAltiumSchDocOptions, type ConvertAltiumToCircuitJsonOptions, type SupportedAltiumDocument, convertAltiumDocumentToCircuitJson, convertAltiumPcbDocToCircuitJson, convertAltiumSchDocToCircuitJson, convertAltiumToCircuitJson };