circuit-json-to-kicad 0.0.17 → 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.
Files changed (2) hide show
  1. package/dist/index.js +53 -19
  2. 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, FpText } from "kicadts";
1352
+ import { Footprint } from "kicadts";
1353
1353
  import { applyToPoint as applyToPoint5 } from "transformation-matrix";
1354
1354
 
1355
1355
  // lib/pcb/stages/utils/CreateSmdPadFromCircuitJson.ts
@@ -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;
@@ -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
- fpTexts.push(refText);
1528
- fpTexts.push(valueText);
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
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.17",
4
+ "version": "0.0.19",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"