circuit-json-to-kicad 0.0.19 → 0.0.20

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.
Files changed (2) hide show
  1. package/dist/index.js +63 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1475,6 +1475,57 @@ function createThruHolePadFromCircuitJson({
1475
1475
  });
1476
1476
  }
1477
1477
 
1478
+ // lib/pcb/stages/utils/CreateNpthPadFromCircuitJson.ts
1479
+ import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
1480
+ function createNpthPadFromCircuitJson({
1481
+ pcbHole,
1482
+ componentCenter
1483
+ }) {
1484
+ if (!("x" in pcbHole && "y" in pcbHole)) {
1485
+ return null;
1486
+ }
1487
+ const relativeX = pcbHole.x - componentCenter.x;
1488
+ const relativeY = -(pcbHole.y - componentCenter.y);
1489
+ let padShape = "circle";
1490
+ let padSize;
1491
+ let drill;
1492
+ if (pcbHole.hole_shape === "circle") {
1493
+ padShape = "circle";
1494
+ const diameter = pcbHole.hole_diameter;
1495
+ padSize = [diameter, diameter];
1496
+ drill = new PadDrill2({
1497
+ diameter
1498
+ });
1499
+ } else if (pcbHole.hole_shape === "oval") {
1500
+ padShape = "oval";
1501
+ const width = pcbHole.hole_width;
1502
+ const height = pcbHole.hole_height;
1503
+ padSize = [width, height];
1504
+ drill = new PadDrill2({
1505
+ oval: true,
1506
+ diameter: width,
1507
+ width: height
1508
+ });
1509
+ } else {
1510
+ padShape = "circle";
1511
+ const diameter = pcbHole.hole_diameter || 1;
1512
+ padSize = [diameter, diameter];
1513
+ drill = new PadDrill2({ diameter });
1514
+ }
1515
+ return new FootprintPad3({
1516
+ number: "",
1517
+ // Non-plated holes have no pad number
1518
+ padType: "np_thru_hole",
1519
+ shape: padShape,
1520
+ at: [relativeX, relativeY, 0],
1521
+ size: padSize,
1522
+ drill,
1523
+ layers: ["*.Cu", "*.Mask"],
1524
+ removeUnusedLayers: false,
1525
+ uuid: crypto.randomUUID()
1526
+ });
1527
+ }
1528
+
1478
1529
  // lib/pcb/stages/utils/CreateFpTextFromCircuitJson.ts
1479
1530
  import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
1480
1531
  function createFpTextFromCircuitJson({
@@ -1589,6 +1640,18 @@ var AddFootprintsStage = class extends ConverterStage {
1589
1640
  padNumber++;
1590
1641
  }
1591
1642
  }
1643
+ const pcbHoles = this.ctx.db.pcb_hole?.list().filter(
1644
+ (hole) => hole.subcircuit_id === component.subcircuit_id
1645
+ ) || [];
1646
+ for (const pcbHole of pcbHoles) {
1647
+ const pad = createNpthPadFromCircuitJson({
1648
+ pcbHole,
1649
+ componentCenter: component.center
1650
+ });
1651
+ if (pad) {
1652
+ fpPads.push(pad);
1653
+ }
1654
+ }
1592
1655
  footprint.fpPads = fpPads;
1593
1656
  const footprints = kicadPcb.footprints;
1594
1657
  footprints.push(footprint);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-json-to-kicad",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"