circuit-json-to-kicad 0.0.17 → 0.0.18
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 +57 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1363,7 +1363,7 @@ function createSmdPadFromCircuitJson({
|
|
|
1363
1363
|
throw new Error("no support for polygon pads (or any pads w/o X/Y) yet");
|
|
1364
1364
|
}
|
|
1365
1365
|
const relativeX = pcbPad.x - componentCenter.x;
|
|
1366
|
-
const relativeY = pcbPad.y - componentCenter.y;
|
|
1366
|
+
const relativeY = -(pcbPad.y - componentCenter.y);
|
|
1367
1367
|
const layerMap = {
|
|
1368
1368
|
top: "F.Cu",
|
|
1369
1369
|
bottom: "B.Cu"
|
|
@@ -1403,7 +1403,7 @@ function createThruHolePadFromCircuitJson({
|
|
|
1403
1403
|
return null;
|
|
1404
1404
|
}
|
|
1405
1405
|
const relativeX = platedHole.x - componentCenter.x;
|
|
1406
|
-
const relativeY = platedHole.y - componentCenter.y;
|
|
1406
|
+
const relativeY = -(platedHole.y - componentCenter.y);
|
|
1407
1407
|
let padShape = "circle";
|
|
1408
1408
|
let padSize;
|
|
1409
1409
|
let drill;
|
|
@@ -1682,7 +1682,47 @@ var AddViasStage = class extends ConverterStage {
|
|
|
1682
1682
|
|
|
1683
1683
|
// lib/pcb/stages/AddGraphicsStage.ts
|
|
1684
1684
|
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";
|
|
1685
1689
|
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
|
|
1686
1726
|
var AddGraphicsStage = class extends ConverterStage {
|
|
1687
1727
|
_step() {
|
|
1688
1728
|
const { kicadPcb, c2kMatPcb } = this.ctx;
|
|
@@ -1699,11 +1739,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1699
1739
|
const startPoint = path.route[i];
|
|
1700
1740
|
const endPoint = path.route[i + 1];
|
|
1701
1741
|
if (!startPoint || !endPoint) continue;
|
|
1702
|
-
const transformedStart =
|
|
1742
|
+
const transformedStart = applyToPoint9(c2kMatPcb, {
|
|
1703
1743
|
x: startPoint.x,
|
|
1704
1744
|
y: startPoint.y
|
|
1705
1745
|
});
|
|
1706
|
-
const transformedEnd =
|
|
1746
|
+
const transformedEnd = applyToPoint9(c2kMatPcb, {
|
|
1707
1747
|
x: endPoint.x,
|
|
1708
1748
|
y: endPoint.y
|
|
1709
1749
|
});
|
|
@@ -1723,6 +1763,18 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1723
1763
|
kicadPcb.graphicLines = graphicLines;
|
|
1724
1764
|
}
|
|
1725
1765
|
}
|
|
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
|
+
}
|
|
1726
1778
|
const pcbBoards = this.ctx.db.pcb_board?.list() || [];
|
|
1727
1779
|
if (pcbBoards.length > 0) {
|
|
1728
1780
|
const board = pcbBoards[0];
|
|
@@ -1744,7 +1796,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1744
1796
|
];
|
|
1745
1797
|
}
|
|
1746
1798
|
const transformedCorners = corners.map(
|
|
1747
|
-
(corner) =>
|
|
1799
|
+
(corner) => applyToPoint9(c2kMatPcb, corner)
|
|
1748
1800
|
);
|
|
1749
1801
|
for (let i = 0; i < transformedCorners.length; i++) {
|
|
1750
1802
|
const start = transformedCorners[i];
|