circuit-json-to-kicad 0.0.34 → 0.0.36
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 +69 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1911,6 +1911,9 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
1911
1911
|
componentRotation: component.rotation || 0
|
|
1912
1912
|
});
|
|
1913
1913
|
if (fpText) {
|
|
1914
|
+
if (sourceComponent?.name && textElement.text === sourceComponent.name) {
|
|
1915
|
+
fpText.type = "reference";
|
|
1916
|
+
}
|
|
1914
1917
|
fpTexts.push(fpText);
|
|
1915
1918
|
}
|
|
1916
1919
|
}
|
|
@@ -2585,7 +2588,12 @@ import {
|
|
|
2585
2588
|
parseKicadSexpr as parseKicadSexpr2,
|
|
2586
2589
|
KicadPcb as KicadPcb2,
|
|
2587
2590
|
FootprintModel as FootprintModel2,
|
|
2588
|
-
At as At2
|
|
2591
|
+
At as At2,
|
|
2592
|
+
EmbeddedFonts as EmbeddedFonts4,
|
|
2593
|
+
FootprintAttr,
|
|
2594
|
+
Property,
|
|
2595
|
+
TextEffects as TextEffects6,
|
|
2596
|
+
TextEffectsFont as TextEffectsFont6
|
|
2589
2597
|
} from "kicadts";
|
|
2590
2598
|
function getBasename(filePath) {
|
|
2591
2599
|
const parts = filePath.split(/[/\\]/);
|
|
@@ -2664,11 +2672,65 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
2664
2672
|
footprint.position = At2.from([0, 0, 0]);
|
|
2665
2673
|
footprint.locked = false;
|
|
2666
2674
|
footprint.placed = false;
|
|
2675
|
+
if (!footprint.descr) {
|
|
2676
|
+
footprint.descr = "";
|
|
2677
|
+
}
|
|
2678
|
+
if (!footprint.tags) {
|
|
2679
|
+
footprint.tags = "";
|
|
2680
|
+
}
|
|
2681
|
+
if (!footprint.embeddedFonts) {
|
|
2682
|
+
footprint.embeddedFonts = new EmbeddedFonts4(false);
|
|
2683
|
+
}
|
|
2684
|
+
if (!footprint.attr) {
|
|
2685
|
+
const attr = new FootprintAttr();
|
|
2686
|
+
const padTypes = (footprint.fpPads ?? []).map((pad) => pad.padType);
|
|
2687
|
+
if (padTypes.some((padType) => padType.includes("thru_hole"))) {
|
|
2688
|
+
attr.type = "through_hole";
|
|
2689
|
+
} else if (padTypes.some((padType) => padType.includes("smd"))) {
|
|
2690
|
+
attr.type = "smd";
|
|
2691
|
+
}
|
|
2692
|
+
footprint.attr = attr;
|
|
2693
|
+
}
|
|
2667
2694
|
footprint.uuid = void 0;
|
|
2668
2695
|
footprint.path = void 0;
|
|
2669
2696
|
footprint.sheetfile = void 0;
|
|
2670
2697
|
footprint.sheetname = void 0;
|
|
2671
|
-
|
|
2698
|
+
const defaultFont = new TextEffectsFont6();
|
|
2699
|
+
defaultFont.size = { width: 1.27, height: 1.27 };
|
|
2700
|
+
defaultFont.thickness = 0.15;
|
|
2701
|
+
const defaultEffects = new TextEffects6({ font: defaultFont });
|
|
2702
|
+
footprint.properties = [
|
|
2703
|
+
new Property({
|
|
2704
|
+
key: "Reference",
|
|
2705
|
+
value: "Ref**",
|
|
2706
|
+
position: [0, 0, 0],
|
|
2707
|
+
layer: "F.SilkS",
|
|
2708
|
+
effects: defaultEffects
|
|
2709
|
+
}),
|
|
2710
|
+
new Property({
|
|
2711
|
+
key: "Value",
|
|
2712
|
+
value: "Val**",
|
|
2713
|
+
position: [0, 0, 0],
|
|
2714
|
+
layer: "F.Fab",
|
|
2715
|
+
effects: defaultEffects
|
|
2716
|
+
}),
|
|
2717
|
+
new Property({
|
|
2718
|
+
key: "Datasheet",
|
|
2719
|
+
value: "",
|
|
2720
|
+
position: [0, 0, 0],
|
|
2721
|
+
layer: "F.Fab",
|
|
2722
|
+
hidden: true,
|
|
2723
|
+
effects: defaultEffects
|
|
2724
|
+
}),
|
|
2725
|
+
new Property({
|
|
2726
|
+
key: "Description",
|
|
2727
|
+
value: "",
|
|
2728
|
+
position: [0, 0, 0],
|
|
2729
|
+
layer: "F.Fab",
|
|
2730
|
+
hidden: true,
|
|
2731
|
+
effects: defaultEffects
|
|
2732
|
+
})
|
|
2733
|
+
];
|
|
2672
2734
|
const texts = footprint.fpTexts ?? [];
|
|
2673
2735
|
for (const text of texts) {
|
|
2674
2736
|
text.uuid = void 0;
|
|
@@ -2691,7 +2753,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
2691
2753
|
for (const model of models) {
|
|
2692
2754
|
if (model.path) {
|
|
2693
2755
|
const modelFilename = getBasename(model.path);
|
|
2694
|
-
const newPath =
|
|
2756
|
+
const newPath = `../../3dmodels/${fpLibraryName}.3dshapes/${modelFilename}`;
|
|
2695
2757
|
const newModel = new FootprintModel2(newPath);
|
|
2696
2758
|
if (model.offset) newModel.offset = model.offset;
|
|
2697
2759
|
if (model.scale) newModel.scale = model.scale;
|
|
@@ -2870,9 +2932,10 @@ function renameKicadFootprint(params) {
|
|
|
2870
2932
|
footprint.libraryLink = newKicadFootprintName;
|
|
2871
2933
|
for (const model of footprint.models) {
|
|
2872
2934
|
const currentPath = model.path;
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2935
|
+
const usesProjectPath = currentPath.includes("${KIPRJMOD}/") || /3dmodels[\\/]/.test(currentPath);
|
|
2936
|
+
if (usesProjectPath) {
|
|
2937
|
+
const filename = currentPath.split(/[\\/]/).pop() ?? "";
|
|
2938
|
+
model.path = `../../3dmodels/${kicadLibraryName}.3dshapes/${filename}`;
|
|
2876
2939
|
}
|
|
2877
2940
|
}
|
|
2878
2941
|
return {
|