circuit-json-to-kicad 0.0.18 → 0.0.19
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/dist/index.js +54 -72
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1349,7 +1349,7 @@ var AddNetsStage = class extends ConverterStage {
|
|
|
1349
1349
|
};
|
|
1350
1350
|
|
|
1351
1351
|
// lib/pcb/stages/AddFootprintsStage.ts
|
|
1352
|
-
import { Footprint
|
|
1352
|
+
import { Footprint } from "kicadts";
|
|
1353
1353
|
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
1354
1354
|
|
|
1355
1355
|
// lib/pcb/stages/utils/CreateSmdPadFromCircuitJson.ts
|
|
@@ -1475,6 +1475,44 @@ function createThruHolePadFromCircuitJson({
|
|
|
1475
1475
|
});
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
|
+
// lib/pcb/stages/utils/CreateFpTextFromCircuitJson.ts
|
|
1479
|
+
import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
1480
|
+
function createFpTextFromCircuitJson({
|
|
1481
|
+
textElement,
|
|
1482
|
+
componentCenter
|
|
1483
|
+
}) {
|
|
1484
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
1485
|
+
return null;
|
|
1486
|
+
}
|
|
1487
|
+
const relativePosition = {
|
|
1488
|
+
x: textElement.anchor_position.x - componentCenter.x,
|
|
1489
|
+
y: -(textElement.anchor_position.y - componentCenter.y)
|
|
1490
|
+
};
|
|
1491
|
+
const layerMap = {
|
|
1492
|
+
top: "F.SilkS",
|
|
1493
|
+
bottom: "B.SilkS"
|
|
1494
|
+
};
|
|
1495
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
1496
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
1497
|
+
const font = new TextEffectsFont4();
|
|
1498
|
+
font.size = { width: fontSize, height: fontSize };
|
|
1499
|
+
const textEffects = new TextEffects4({
|
|
1500
|
+
font
|
|
1501
|
+
});
|
|
1502
|
+
const rotation = textElement.ccw_rotation || 0;
|
|
1503
|
+
return new FpText({
|
|
1504
|
+
type: "user",
|
|
1505
|
+
text: textElement.text,
|
|
1506
|
+
position: {
|
|
1507
|
+
x: relativePosition.x,
|
|
1508
|
+
y: relativePosition.y,
|
|
1509
|
+
angle: rotation
|
|
1510
|
+
},
|
|
1511
|
+
layer: kicadLayer,
|
|
1512
|
+
effects: textEffects
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1478
1516
|
// lib/pcb/stages/AddFootprintsStage.ts
|
|
1479
1517
|
var AddFootprintsStage = class extends ConverterStage {
|
|
1480
1518
|
componentsProcessed = 0;
|
|
@@ -1509,23 +1547,19 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
1509
1547
|
at: [transformedPos.x, transformedPos.y, component.rotation || 0],
|
|
1510
1548
|
uuid: crypto.randomUUID()
|
|
1511
1549
|
});
|
|
1512
|
-
const refText = new FpText({
|
|
1513
|
-
type: "reference",
|
|
1514
|
-
text: componentName,
|
|
1515
|
-
position: [0, -1.5, 0],
|
|
1516
|
-
layer: "F.SilkS",
|
|
1517
|
-
uuid: crypto.randomUUID()
|
|
1518
|
-
});
|
|
1519
|
-
const valueText = new FpText({
|
|
1520
|
-
type: "value",
|
|
1521
|
-
text: footprintName,
|
|
1522
|
-
position: [0, 1.5, 0],
|
|
1523
|
-
layer: "F.Fab",
|
|
1524
|
-
uuid: crypto.randomUUID()
|
|
1525
|
-
});
|
|
1526
1550
|
const fpTexts = footprint.fpTexts;
|
|
1527
|
-
|
|
1528
|
-
|
|
1551
|
+
const pcbSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter(
|
|
1552
|
+
(text) => text.pcb_component_id === component.pcb_component_id
|
|
1553
|
+
) || [];
|
|
1554
|
+
for (const textElement of pcbSilkscreenTexts) {
|
|
1555
|
+
const fpText = createFpTextFromCircuitJson({
|
|
1556
|
+
textElement,
|
|
1557
|
+
componentCenter: component.center
|
|
1558
|
+
});
|
|
1559
|
+
if (fpText) {
|
|
1560
|
+
fpTexts.push(fpText);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1529
1563
|
footprint.fpTexts = fpTexts;
|
|
1530
1564
|
const pcbPads = this.ctx.db.pcb_smtpad?.list().filter(
|
|
1531
1565
|
(pad) => pad.pcb_component_id === component.pcb_component_id
|
|
@@ -1682,47 +1716,7 @@ var AddViasStage = class extends ConverterStage {
|
|
|
1682
1716
|
|
|
1683
1717
|
// lib/pcb/stages/AddGraphicsStage.ts
|
|
1684
1718
|
import { GrLine } from "kicadts";
|
|
1685
|
-
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
1686
|
-
|
|
1687
|
-
// lib/pcb/stages/utils/CreateGrTextFromCircuitJson.ts
|
|
1688
|
-
import { GrText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
1689
1719
|
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
1690
|
-
function createGrTextFromCircuitJson({
|
|
1691
|
-
textElement,
|
|
1692
|
-
transformationMatrix
|
|
1693
|
-
}) {
|
|
1694
|
-
if (!textElement.text || !textElement.anchor_position) {
|
|
1695
|
-
return null;
|
|
1696
|
-
}
|
|
1697
|
-
const transformedPosition = applyToPoint8(transformationMatrix, {
|
|
1698
|
-
x: textElement.anchor_position.x,
|
|
1699
|
-
y: textElement.anchor_position.y
|
|
1700
|
-
});
|
|
1701
|
-
const layerMap = {
|
|
1702
|
-
top: "F.SilkS",
|
|
1703
|
-
bottom: "B.SilkS"
|
|
1704
|
-
};
|
|
1705
|
-
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
1706
|
-
const fontSize = (textElement.font_size || 1) / 2;
|
|
1707
|
-
const font = new TextEffectsFont4();
|
|
1708
|
-
font.size = { width: fontSize, height: fontSize };
|
|
1709
|
-
const textEffects = new TextEffects4({
|
|
1710
|
-
font
|
|
1711
|
-
});
|
|
1712
|
-
const rotation = textElement.ccw_rotation || 0;
|
|
1713
|
-
return new GrText({
|
|
1714
|
-
text: textElement.text,
|
|
1715
|
-
position: {
|
|
1716
|
-
x: transformedPosition.x,
|
|
1717
|
-
y: transformedPosition.y,
|
|
1718
|
-
angle: rotation
|
|
1719
|
-
},
|
|
1720
|
-
layer: kicadLayer,
|
|
1721
|
-
effects: textEffects
|
|
1722
|
-
});
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
// lib/pcb/stages/AddGraphicsStage.ts
|
|
1726
1720
|
var AddGraphicsStage = class extends ConverterStage {
|
|
1727
1721
|
_step() {
|
|
1728
1722
|
const { kicadPcb, c2kMatPcb } = this.ctx;
|
|
@@ -1739,11 +1733,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1739
1733
|
const startPoint = path.route[i];
|
|
1740
1734
|
const endPoint = path.route[i + 1];
|
|
1741
1735
|
if (!startPoint || !endPoint) continue;
|
|
1742
|
-
const transformedStart =
|
|
1736
|
+
const transformedStart = applyToPoint8(c2kMatPcb, {
|
|
1743
1737
|
x: startPoint.x,
|
|
1744
1738
|
y: startPoint.y
|
|
1745
1739
|
});
|
|
1746
|
-
const transformedEnd =
|
|
1740
|
+
const transformedEnd = applyToPoint8(c2kMatPcb, {
|
|
1747
1741
|
x: endPoint.x,
|
|
1748
1742
|
y: endPoint.y
|
|
1749
1743
|
});
|
|
@@ -1763,18 +1757,6 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1763
1757
|
kicadPcb.graphicLines = graphicLines;
|
|
1764
1758
|
}
|
|
1765
1759
|
}
|
|
1766
|
-
const pcbSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list() || [];
|
|
1767
|
-
for (const textElement of pcbSilkscreenTexts) {
|
|
1768
|
-
const grText = createGrTextFromCircuitJson({
|
|
1769
|
-
textElement,
|
|
1770
|
-
transformationMatrix: c2kMatPcb
|
|
1771
|
-
});
|
|
1772
|
-
if (grText) {
|
|
1773
|
-
const graphicTexts = kicadPcb.graphicTexts || [];
|
|
1774
|
-
graphicTexts.push(grText);
|
|
1775
|
-
kicadPcb.graphicTexts = graphicTexts;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
1760
|
const pcbBoards = this.ctx.db.pcb_board?.list() || [];
|
|
1779
1761
|
if (pcbBoards.length > 0) {
|
|
1780
1762
|
const board = pcbBoards[0];
|
|
@@ -1796,7 +1778,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1796
1778
|
];
|
|
1797
1779
|
}
|
|
1798
1780
|
const transformedCorners = corners.map(
|
|
1799
|
-
(corner) =>
|
|
1781
|
+
(corner) => applyToPoint8(c2kMatPcb, corner)
|
|
1800
1782
|
);
|
|
1801
1783
|
for (let i = 0; i < transformedCorners.length; i++) {
|
|
1802
1784
|
const start = transformedCorners[i];
|