circuit-json-to-kicad 0.0.14 → 0.0.16
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 +330 -51
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -109,35 +109,32 @@ import { applyToPoint, scale as createScaleMatrix } from "transformation-matrix"
|
|
|
109
109
|
var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
110
110
|
_step() {
|
|
111
111
|
const { kicadSch, db } = this.ctx;
|
|
112
|
-
const schematicComponents = db.schematic_component.list();
|
|
113
|
-
if (schematicComponents.length === 0) {
|
|
114
|
-
this.finished = true;
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
112
|
const libSymbols = new LibSymbols();
|
|
118
113
|
const librarySymbols = [];
|
|
114
|
+
const schematicComponents = db.schematic_component.list();
|
|
119
115
|
for (const schematicComponent of schematicComponents) {
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
if (!symbolName) {
|
|
124
|
-
continue;
|
|
116
|
+
const libSymbol = this.createLibrarySymbolForComponent(schematicComponent);
|
|
117
|
+
if (libSymbol) {
|
|
118
|
+
librarySymbols.push(libSymbol);
|
|
125
119
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
120
|
+
}
|
|
121
|
+
const netLabels = db.schematic_net_label?.list?.() || [];
|
|
122
|
+
for (const netLabel of netLabels) {
|
|
123
|
+
if (netLabel.symbol_name) {
|
|
124
|
+
const isPower = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id)?.is_power : false;
|
|
125
|
+
const isGround = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id)?.is_ground : false;
|
|
126
|
+
const isPowerOrGround = isPower || isGround;
|
|
127
|
+
if (isPowerOrGround) {
|
|
128
|
+
const libSymbol = this.createLibrarySymbolForNetLabel({
|
|
129
|
+
netLabel,
|
|
130
|
+
isPower: isPower ?? false,
|
|
131
|
+
isGround: isGround ?? false
|
|
132
|
+
});
|
|
133
|
+
if (libSymbol) {
|
|
134
|
+
librarySymbols.push(libSymbol);
|
|
135
|
+
}
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
|
-
const libSymbol = this.createLibrarySymbolFromSchematicSymbol({
|
|
136
|
-
symbolData,
|
|
137
|
-
sourceComp,
|
|
138
|
-
schematicComponent
|
|
139
|
-
});
|
|
140
|
-
librarySymbols.push(libSymbol);
|
|
141
138
|
}
|
|
142
139
|
libSymbols.symbols = librarySymbols;
|
|
143
140
|
if (kicadSch) {
|
|
@@ -145,6 +142,61 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
145
142
|
}
|
|
146
143
|
this.finished = true;
|
|
147
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Create library symbol for a schematic component
|
|
147
|
+
*/
|
|
148
|
+
createLibrarySymbolForComponent(schematicComponent) {
|
|
149
|
+
const { db } = this.ctx;
|
|
150
|
+
const sourceComp = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
|
|
151
|
+
if (!sourceComp) return null;
|
|
152
|
+
const symbolName = schematicComponent.symbol_name || (sourceComp.ftype === "simple_chip" ? `generic_chip_${schematicComponent.source_component_id}` : null);
|
|
153
|
+
if (!symbolName) return null;
|
|
154
|
+
const symbolData = this.getSymbolData(symbolName, schematicComponent);
|
|
155
|
+
if (!symbolData) return null;
|
|
156
|
+
const libId = getLibraryId(sourceComp, schematicComponent);
|
|
157
|
+
const isChip = sourceComp.ftype === "simple_chip";
|
|
158
|
+
return this.createLibrarySymbol({
|
|
159
|
+
libId,
|
|
160
|
+
symbolData,
|
|
161
|
+
isChip,
|
|
162
|
+
schematicComponent,
|
|
163
|
+
description: this.getDescription(sourceComp),
|
|
164
|
+
keywords: this.getKeywords(sourceComp),
|
|
165
|
+
fpFilters: this.getFpFilters(sourceComp)
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Create library symbol for a schematic net label with symbol_name
|
|
170
|
+
*/
|
|
171
|
+
createLibrarySymbolForNetLabel({
|
|
172
|
+
netLabel,
|
|
173
|
+
isPower,
|
|
174
|
+
isGround
|
|
175
|
+
}) {
|
|
176
|
+
const symbolName = netLabel.symbol_name;
|
|
177
|
+
if (!symbolName) return null;
|
|
178
|
+
const symbolData = symbols[symbolName];
|
|
179
|
+
if (!symbolData) return null;
|
|
180
|
+
const libId = `Custom:${symbolName}`;
|
|
181
|
+
return this.createLibrarySymbol({
|
|
182
|
+
libId,
|
|
183
|
+
symbolData,
|
|
184
|
+
isChip: false,
|
|
185
|
+
schematicComponent: void 0,
|
|
186
|
+
description: isPower ? "Power net label" : isGround ? "Ground net label" : "Net symbol",
|
|
187
|
+
keywords: isPower ? "power net" : isGround ? "ground net" : "net",
|
|
188
|
+
fpFilters: ""
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get symbol data from schematic-symbols or generate for generic chips
|
|
193
|
+
*/
|
|
194
|
+
getSymbolData(symbolName, schematicComponent) {
|
|
195
|
+
if (symbolName.startsWith("generic_chip_")) {
|
|
196
|
+
return this.createGenericChipSymbolData(schematicComponent, this.ctx.db);
|
|
197
|
+
}
|
|
198
|
+
return symbols[symbolName] || null;
|
|
199
|
+
}
|
|
148
200
|
/**
|
|
149
201
|
* Create generic chip symbol data for chips without a symbol_name
|
|
150
202
|
*/
|
|
@@ -182,14 +234,18 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
182
234
|
};
|
|
183
235
|
}
|
|
184
236
|
/**
|
|
185
|
-
*
|
|
237
|
+
* Create a KiCad library symbol from symbol data
|
|
238
|
+
* This is the core method that handles both components and net labels
|
|
186
239
|
*/
|
|
187
|
-
|
|
240
|
+
createLibrarySymbol({
|
|
241
|
+
libId,
|
|
188
242
|
symbolData,
|
|
189
|
-
|
|
190
|
-
schematicComponent
|
|
243
|
+
isChip,
|
|
244
|
+
schematicComponent,
|
|
245
|
+
description,
|
|
246
|
+
keywords,
|
|
247
|
+
fpFilters
|
|
191
248
|
}) {
|
|
192
|
-
const libId = getLibraryId(sourceComp, schematicComponent);
|
|
193
249
|
const symbol = new SchematicSymbol({
|
|
194
250
|
libraryId: libId,
|
|
195
251
|
excludeFromSim: false,
|
|
@@ -197,13 +253,18 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
197
253
|
onBoard: true
|
|
198
254
|
});
|
|
199
255
|
const pinNumbers = new SymbolPinNumbers();
|
|
200
|
-
pinNumbers.hide =
|
|
256
|
+
pinNumbers.hide = !isChip;
|
|
201
257
|
symbol._sxPinNumbers = pinNumbers;
|
|
202
258
|
const pinNames = new SymbolPinNames();
|
|
203
|
-
pinNames.offset =
|
|
259
|
+
pinNames.offset = isChip ? 1.27 : 0;
|
|
204
260
|
symbol._sxPinNames = pinNames;
|
|
205
|
-
this.addSymbolProperties(
|
|
206
|
-
|
|
261
|
+
this.addSymbolProperties({
|
|
262
|
+
symbol,
|
|
263
|
+
libId,
|
|
264
|
+
description,
|
|
265
|
+
keywords,
|
|
266
|
+
fpFilters
|
|
267
|
+
});
|
|
207
268
|
const drawingSymbol = this.createDrawingSubsymbol({
|
|
208
269
|
libId,
|
|
209
270
|
symbolData,
|
|
@@ -223,7 +284,13 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
223
284
|
/**
|
|
224
285
|
* Add properties to the library symbol
|
|
225
286
|
*/
|
|
226
|
-
addSymbolProperties(
|
|
287
|
+
addSymbolProperties({
|
|
288
|
+
symbol,
|
|
289
|
+
libId,
|
|
290
|
+
description,
|
|
291
|
+
keywords,
|
|
292
|
+
fpFilters
|
|
293
|
+
}) {
|
|
227
294
|
const refPrefix = libId.split(":")[1]?.[0] || "U";
|
|
228
295
|
const properties = [
|
|
229
296
|
{
|
|
@@ -250,21 +317,21 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
250
317
|
},
|
|
251
318
|
{
|
|
252
319
|
key: "Description",
|
|
253
|
-
value:
|
|
320
|
+
value: description,
|
|
254
321
|
id: 4,
|
|
255
322
|
at: [0, 0, 0],
|
|
256
323
|
hide: true
|
|
257
324
|
},
|
|
258
325
|
{
|
|
259
326
|
key: "ki_keywords",
|
|
260
|
-
value:
|
|
327
|
+
value: keywords,
|
|
261
328
|
id: 5,
|
|
262
329
|
at: [0, 0, 0],
|
|
263
330
|
hide: true
|
|
264
331
|
},
|
|
265
332
|
{
|
|
266
333
|
key: "ki_fp_filters",
|
|
267
|
-
value:
|
|
334
|
+
value: fpFilters,
|
|
268
335
|
id: 6,
|
|
269
336
|
at: [0, 0, 0],
|
|
270
337
|
hide: true
|
|
@@ -745,9 +812,220 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
745
812
|
}
|
|
746
813
|
};
|
|
747
814
|
|
|
815
|
+
// lib/schematic/stages/AddSchematicNetLabelsStage.ts
|
|
816
|
+
import {
|
|
817
|
+
SchematicSymbol as SchematicSymbol3,
|
|
818
|
+
SymbolLibId as SymbolLibId2,
|
|
819
|
+
SymbolProperty as SymbolProperty3,
|
|
820
|
+
SymbolPin as SymbolPin3,
|
|
821
|
+
SymbolInstances as SymbolInstances2,
|
|
822
|
+
SymbolInstancesProject as SymbolInstancesProject2,
|
|
823
|
+
SymbolInstancePath as SymbolInstancePath2,
|
|
824
|
+
TextEffects as TextEffects3,
|
|
825
|
+
TextEffectsFont as TextEffectsFont3,
|
|
826
|
+
TextEffectsJustify as TextEffectsJustify2,
|
|
827
|
+
GlobalLabel
|
|
828
|
+
} from "kicadts";
|
|
829
|
+
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
830
|
+
var AddSchematicNetLabelsStage = class extends ConverterStage {
|
|
831
|
+
_step() {
|
|
832
|
+
const { kicadSch, db } = this.ctx;
|
|
833
|
+
const netLabels = db.schematic_net_label?.list?.() || [];
|
|
834
|
+
if (netLabels.length === 0) {
|
|
835
|
+
this.finished = true;
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (!this.ctx.c2kMatSch) {
|
|
839
|
+
this.finished = true;
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const symbols3 = [];
|
|
843
|
+
const globalLabels = [];
|
|
844
|
+
for (const netLabel of netLabels) {
|
|
845
|
+
const labelText = netLabel.text || "";
|
|
846
|
+
const symbolName = netLabel.symbol_name;
|
|
847
|
+
if (symbolName) {
|
|
848
|
+
const symbol = this.createSymbolFromNetLabel(
|
|
849
|
+
netLabel,
|
|
850
|
+
labelText,
|
|
851
|
+
symbolName
|
|
852
|
+
);
|
|
853
|
+
if (symbol) {
|
|
854
|
+
symbols3.push(symbol);
|
|
855
|
+
}
|
|
856
|
+
} else {
|
|
857
|
+
const label = this.createGlobalLabel(netLabel, labelText);
|
|
858
|
+
if (label) {
|
|
859
|
+
globalLabels.push(label);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (kicadSch && symbols3.length > 0) {
|
|
864
|
+
const existingSymbols = kicadSch.symbols || [];
|
|
865
|
+
kicadSch.symbols = [...existingSymbols, ...symbols3];
|
|
866
|
+
}
|
|
867
|
+
if (kicadSch && globalLabels.length > 0) {
|
|
868
|
+
kicadSch.globalLabels = [
|
|
869
|
+
...kicadSch.globalLabels || [],
|
|
870
|
+
...globalLabels
|
|
871
|
+
];
|
|
872
|
+
}
|
|
873
|
+
this.finished = true;
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Create a KiCad symbol instance from a net label with a symbol_name
|
|
877
|
+
* These are treated like power/ground symbols (e.g., vcc_up, ground_down)
|
|
878
|
+
* Uses anchor_position as the primary coordinate source
|
|
879
|
+
*/
|
|
880
|
+
createSymbolFromNetLabel(netLabel, labelText, symbolName) {
|
|
881
|
+
if (!this.ctx.c2kMatSch) return null;
|
|
882
|
+
const { x, y } = applyToPoint3(this.ctx.c2kMatSch, {
|
|
883
|
+
x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
|
|
884
|
+
y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
|
|
885
|
+
});
|
|
886
|
+
const uuid = crypto.randomUUID();
|
|
887
|
+
const symbol = new SchematicSymbol3({
|
|
888
|
+
at: [x, y, 0],
|
|
889
|
+
unit: 1,
|
|
890
|
+
excludeFromSim: false,
|
|
891
|
+
inBom: true,
|
|
892
|
+
onBoard: true,
|
|
893
|
+
dnp: false,
|
|
894
|
+
uuid,
|
|
895
|
+
fieldsAutoplaced: true
|
|
896
|
+
});
|
|
897
|
+
const libId = `Custom:${symbolName}`;
|
|
898
|
+
const symLibId = new SymbolLibId2(libId);
|
|
899
|
+
symbol._sxLibId = symLibId;
|
|
900
|
+
const isUpSymbol = symbolName.includes("_up") || symbolName.toLowerCase().includes("vcc");
|
|
901
|
+
const referenceOffset = isUpSymbol ? -4 : 4;
|
|
902
|
+
const valueOffset = isUpSymbol ? -6 : 6;
|
|
903
|
+
const referenceProperty = new SymbolProperty3({
|
|
904
|
+
key: "Reference",
|
|
905
|
+
value: labelText,
|
|
906
|
+
// Use the label text as the reference
|
|
907
|
+
id: 0,
|
|
908
|
+
at: [x, y + referenceOffset, 0],
|
|
909
|
+
effects: this.createTextEffects(1.27, false)
|
|
910
|
+
});
|
|
911
|
+
const valueProperty = new SymbolProperty3({
|
|
912
|
+
key: "Value",
|
|
913
|
+
value: labelText,
|
|
914
|
+
id: 1,
|
|
915
|
+
at: [x, y + valueOffset, 0],
|
|
916
|
+
effects: this.createTextEffects(1.27, true)
|
|
917
|
+
});
|
|
918
|
+
const footprintProperty = new SymbolProperty3({
|
|
919
|
+
key: "Footprint",
|
|
920
|
+
value: "",
|
|
921
|
+
id: 2,
|
|
922
|
+
at: [x - 1.778, y, 90],
|
|
923
|
+
effects: this.createTextEffects(1.27, true)
|
|
924
|
+
});
|
|
925
|
+
const datasheetProperty = new SymbolProperty3({
|
|
926
|
+
key: "Datasheet",
|
|
927
|
+
value: "~",
|
|
928
|
+
id: 3,
|
|
929
|
+
at: [x, y, 0],
|
|
930
|
+
effects: this.createTextEffects(1.27, true)
|
|
931
|
+
});
|
|
932
|
+
const descriptionProperty = new SymbolProperty3({
|
|
933
|
+
key: "Description",
|
|
934
|
+
value: `Power/Net symbol: ${labelText}`,
|
|
935
|
+
id: 4,
|
|
936
|
+
at: [x, y, 0],
|
|
937
|
+
effects: this.createTextEffects(1.27, true)
|
|
938
|
+
});
|
|
939
|
+
symbol.properties.push(
|
|
940
|
+
referenceProperty,
|
|
941
|
+
valueProperty,
|
|
942
|
+
footprintProperty,
|
|
943
|
+
datasheetProperty,
|
|
944
|
+
descriptionProperty
|
|
945
|
+
);
|
|
946
|
+
const pin = new SymbolPin3();
|
|
947
|
+
pin.numberString = "1";
|
|
948
|
+
pin.uuid = crypto.randomUUID();
|
|
949
|
+
symbol.pins.push(pin);
|
|
950
|
+
const { kicadSch } = this.ctx;
|
|
951
|
+
const instances = new SymbolInstances2();
|
|
952
|
+
const project = new SymbolInstancesProject2("");
|
|
953
|
+
const path = new SymbolInstancePath2(`/${kicadSch?.uuid?.value || ""}`);
|
|
954
|
+
path.reference = labelText;
|
|
955
|
+
path.unit = 1;
|
|
956
|
+
project.paths.push(path);
|
|
957
|
+
instances.projects.push(project);
|
|
958
|
+
symbol._sxInstances = instances;
|
|
959
|
+
return symbol;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Create a KiCad global label from a schematic_net_label without a symbol_name
|
|
963
|
+
* Uses anchor_position as the primary coordinate source for the arrow anchor point
|
|
964
|
+
*/
|
|
965
|
+
createGlobalLabel(netLabel, labelText) {
|
|
966
|
+
if (!this.ctx.c2kMatSch || !this.ctx.kicadSch) return null;
|
|
967
|
+
const { x, y } = applyToPoint3(this.ctx.c2kMatSch, {
|
|
968
|
+
x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
|
|
969
|
+
y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
|
|
970
|
+
});
|
|
971
|
+
const anchorSide = netLabel.anchor_side || "left";
|
|
972
|
+
const angleMap = {
|
|
973
|
+
left: 0,
|
|
974
|
+
// Anchor on left, arrow points right
|
|
975
|
+
right: 180,
|
|
976
|
+
// Anchor on right, arrow points left
|
|
977
|
+
top: 270,
|
|
978
|
+
// Anchor on top, arrow points down
|
|
979
|
+
bottom: 90
|
|
980
|
+
// Anchor on bottom, arrow points up
|
|
981
|
+
};
|
|
982
|
+
const angle = angleMap[anchorSide] || 0;
|
|
983
|
+
const justifyMap = {
|
|
984
|
+
left: { horizontal: "left" },
|
|
985
|
+
// Anchor on left, text on left
|
|
986
|
+
right: { horizontal: "right" },
|
|
987
|
+
// Anchor on right, text on right
|
|
988
|
+
top: { vertical: "top" },
|
|
989
|
+
// Anchor on top, text on top
|
|
990
|
+
bottom: { vertical: "bottom" }
|
|
991
|
+
// Anchor on bottom, text on bottom
|
|
992
|
+
};
|
|
993
|
+
const justify = justifyMap[anchorSide] || {};
|
|
994
|
+
const effects = this.createTextEffects(1.27, false);
|
|
995
|
+
if (Object.keys(justify).length > 0) {
|
|
996
|
+
effects.justify = new TextEffectsJustify2(justify);
|
|
997
|
+
}
|
|
998
|
+
const globalLabel = new GlobalLabel({
|
|
999
|
+
value: labelText,
|
|
1000
|
+
at: [x, y, angle],
|
|
1001
|
+
effects,
|
|
1002
|
+
uuid: crypto.randomUUID(),
|
|
1003
|
+
fieldsAutoplaced: true
|
|
1004
|
+
});
|
|
1005
|
+
return globalLabel;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Creates text effects for properties and labels
|
|
1009
|
+
*/
|
|
1010
|
+
createTextEffects(size, hide = false) {
|
|
1011
|
+
const font = new TextEffectsFont3();
|
|
1012
|
+
font.size = { height: size, width: size };
|
|
1013
|
+
return new TextEffects3({
|
|
1014
|
+
font,
|
|
1015
|
+
hiddenText: hide
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
getOutput() {
|
|
1019
|
+
if (!this.ctx.kicadSch) {
|
|
1020
|
+
throw new Error("kicadSch is not initialized");
|
|
1021
|
+
}
|
|
1022
|
+
return this.ctx.kicadSch;
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
|
|
748
1026
|
// lib/schematic/stages/AddSchematicTracesStage.ts
|
|
749
1027
|
import { Wire, Pts as Pts2, Xy as Xy2, Stroke as Stroke2, Junction } from "kicadts";
|
|
750
|
-
import { applyToPoint as
|
|
1028
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
751
1029
|
var AddSchematicTracesStage = class extends ConverterStage {
|
|
752
1030
|
_step() {
|
|
753
1031
|
const { kicadSch, db } = this.ctx;
|
|
@@ -785,11 +1063,11 @@ var AddSchematicTracesStage = class extends ConverterStage {
|
|
|
785
1063
|
"Schematic transformation matrix not initialized in context"
|
|
786
1064
|
);
|
|
787
1065
|
}
|
|
788
|
-
const from =
|
|
1066
|
+
const from = applyToPoint4(this.ctx.c2kMatSch, {
|
|
789
1067
|
x: edge.from.x,
|
|
790
1068
|
y: edge.from.y
|
|
791
1069
|
});
|
|
792
|
-
const to =
|
|
1070
|
+
const to = applyToPoint4(this.ctx.c2kMatSch, {
|
|
793
1071
|
x: edge.to.x,
|
|
794
1072
|
y: edge.to.y
|
|
795
1073
|
});
|
|
@@ -815,7 +1093,7 @@ var AddSchematicTracesStage = class extends ConverterStage {
|
|
|
815
1093
|
"Schematic transformation matrix not initialized in context"
|
|
816
1094
|
);
|
|
817
1095
|
}
|
|
818
|
-
const { x, y } =
|
|
1096
|
+
const { x, y } = applyToPoint4(this.ctx.c2kMatSch, {
|
|
819
1097
|
x: junction.x,
|
|
820
1098
|
y: junction.y
|
|
821
1099
|
});
|
|
@@ -938,6 +1216,7 @@ var CircuitJsonToKicadSchConverter = class {
|
|
|
938
1216
|
new InitializeSchematicStage(circuitJson, this.ctx),
|
|
939
1217
|
new AddLibrarySymbolsStage(circuitJson, this.ctx),
|
|
940
1218
|
new AddSchematicSymbolsStage(circuitJson, this.ctx),
|
|
1219
|
+
new AddSchematicNetLabelsStage(circuitJson, this.ctx),
|
|
941
1220
|
new AddSchematicTracesStage(circuitJson, this.ctx),
|
|
942
1221
|
new AddSheetInstancesStage(circuitJson, this.ctx)
|
|
943
1222
|
];
|
|
@@ -1071,7 +1350,7 @@ var AddNetsStage = class extends ConverterStage {
|
|
|
1071
1350
|
|
|
1072
1351
|
// lib/pcb/stages/AddFootprintsStage.ts
|
|
1073
1352
|
import { Footprint, FpText, FootprintPad } from "kicadts";
|
|
1074
|
-
import { applyToPoint as
|
|
1353
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
1075
1354
|
var AddFootprintsStage = class extends ConverterStage {
|
|
1076
1355
|
componentsProcessed = 0;
|
|
1077
1356
|
pcbComponents = [];
|
|
@@ -1095,7 +1374,7 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
1095
1374
|
const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
|
|
1096
1375
|
const footprintName = sourceComponent?.ftype || "Unknown";
|
|
1097
1376
|
const componentName = sourceComponent?.name || `Component_${this.componentsProcessed}`;
|
|
1098
|
-
const transformedPos =
|
|
1377
|
+
const transformedPos = applyToPoint5(c2kMatPcb, {
|
|
1099
1378
|
x: component.center.x,
|
|
1100
1379
|
y: component.center.y
|
|
1101
1380
|
});
|
|
@@ -1176,7 +1455,7 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
1176
1455
|
|
|
1177
1456
|
// lib/pcb/stages/AddTracesStage.ts
|
|
1178
1457
|
import { Segment, SegmentNet } from "kicadts";
|
|
1179
|
-
import { applyToPoint as
|
|
1458
|
+
import { applyToPoint as applyToPoint6 } from "transformation-matrix";
|
|
1180
1459
|
var AddTracesStage = class extends ConverterStage {
|
|
1181
1460
|
tracesProcessed = 0;
|
|
1182
1461
|
pcbTraces = [];
|
|
@@ -1204,11 +1483,11 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
1204
1483
|
for (let i = 0; i < trace.route.length - 1; i++) {
|
|
1205
1484
|
const startPoint = trace.route[i];
|
|
1206
1485
|
const endPoint = trace.route[i + 1];
|
|
1207
|
-
const transformedStart =
|
|
1486
|
+
const transformedStart = applyToPoint6(c2kMatPcb, {
|
|
1208
1487
|
x: startPoint.x,
|
|
1209
1488
|
y: startPoint.y
|
|
1210
1489
|
});
|
|
1211
|
-
const transformedEnd =
|
|
1490
|
+
const transformedEnd = applyToPoint6(c2kMatPcb, {
|
|
1212
1491
|
x: endPoint.x,
|
|
1213
1492
|
y: endPoint.y
|
|
1214
1493
|
});
|
|
@@ -1242,7 +1521,7 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
1242
1521
|
|
|
1243
1522
|
// lib/pcb/stages/AddViasStage.ts
|
|
1244
1523
|
import { Via, ViaNet } from "kicadts";
|
|
1245
|
-
import { applyToPoint as
|
|
1524
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
1246
1525
|
var AddViasStage = class extends ConverterStage {
|
|
1247
1526
|
viasProcessed = 0;
|
|
1248
1527
|
pcbVias = [];
|
|
@@ -1263,7 +1542,7 @@ var AddViasStage = class extends ConverterStage {
|
|
|
1263
1542
|
return;
|
|
1264
1543
|
}
|
|
1265
1544
|
const via = this.pcbVias[this.viasProcessed];
|
|
1266
|
-
const transformedPos =
|
|
1545
|
+
const transformedPos = applyToPoint7(c2kMatPcb, {
|
|
1267
1546
|
x: via.x,
|
|
1268
1547
|
y: via.y
|
|
1269
1548
|
});
|
|
@@ -1290,7 +1569,7 @@ var AddViasStage = class extends ConverterStage {
|
|
|
1290
1569
|
|
|
1291
1570
|
// lib/pcb/stages/AddGraphicsStage.ts
|
|
1292
1571
|
import { GrLine } from "kicadts";
|
|
1293
|
-
import { applyToPoint as
|
|
1572
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
1294
1573
|
var AddGraphicsStage = class extends ConverterStage {
|
|
1295
1574
|
_step() {
|
|
1296
1575
|
const { kicadPcb, c2kMatPcb } = this.ctx;
|
|
@@ -1307,11 +1586,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1307
1586
|
const startPoint = path.route[i];
|
|
1308
1587
|
const endPoint = path.route[i + 1];
|
|
1309
1588
|
if (!startPoint || !endPoint) continue;
|
|
1310
|
-
const transformedStart =
|
|
1589
|
+
const transformedStart = applyToPoint8(c2kMatPcb, {
|
|
1311
1590
|
x: startPoint.x,
|
|
1312
1591
|
y: startPoint.y
|
|
1313
1592
|
});
|
|
1314
|
-
const transformedEnd =
|
|
1593
|
+
const transformedEnd = applyToPoint8(c2kMatPcb, {
|
|
1315
1594
|
x: endPoint.x,
|
|
1316
1595
|
y: endPoint.y
|
|
1317
1596
|
});
|
|
@@ -1352,7 +1631,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
1352
1631
|
];
|
|
1353
1632
|
}
|
|
1354
1633
|
const transformedCorners = corners.map(
|
|
1355
|
-
(corner) =>
|
|
1634
|
+
(corner) => applyToPoint8(c2kMatPcb, corner)
|
|
1356
1635
|
);
|
|
1357
1636
|
for (let i = 0; i < transformedCorners.length; i++) {
|
|
1358
1637
|
const start = transformedCorners[i];
|
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.
|
|
4
|
+
"version": "0.0.16",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@types/bun": "latest",
|
|
21
21
|
"circuit-json": "^0.0.267",
|
|
22
22
|
"circuit-to-svg": "^0.0.208",
|
|
23
|
-
"kicadts": "^0.0.
|
|
23
|
+
"kicadts": "^0.0.10",
|
|
24
24
|
"schematic-symbols": "^0.0.202",
|
|
25
25
|
"sharp": "^0.34.4",
|
|
26
26
|
"transformation-matrix": "^3.1.0",
|