@tscircuit/cli 0.1.2225 → 0.1.2226
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/cli/main.js +443 -229
- package/dist/lib/index.js +393 -179
- package/package.json +2 -2
package/dist/lib/index.js
CHANGED
|
@@ -69109,7 +69109,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
69109
69109
|
}));
|
|
69110
69110
|
};
|
|
69111
69111
|
// package.json
|
|
69112
|
-
var version = "0.1.
|
|
69112
|
+
var version = "0.1.2225";
|
|
69113
69113
|
var package_default = {
|
|
69114
69114
|
name: "@tscircuit/cli",
|
|
69115
69115
|
version,
|
|
@@ -69161,7 +69161,7 @@ var package_default = {
|
|
|
69161
69161
|
"circuit-json-to-fdm-component-box": "^0.0.2",
|
|
69162
69162
|
"circuit-json-to-footprinter": "^0.0.58",
|
|
69163
69163
|
"circuit-json-to-gerber": "^0.0.105",
|
|
69164
|
-
"circuit-json-to-kicad": "0.0.
|
|
69164
|
+
"circuit-json-to-kicad": "0.0.230",
|
|
69165
69165
|
"circuit-json-to-pnp-csv": "^0.0.18",
|
|
69166
69166
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
69167
69167
|
"circuit-json-to-spice": "^0.0.45",
|
|
@@ -71948,7 +71948,7 @@ import {
|
|
|
71948
71948
|
import { Paper, Uuid as Uuid4 } from "kicadts";
|
|
71949
71949
|
import { KicadPcb as KicadPcb2 } from "kicadts";
|
|
71950
71950
|
import { cju as cju2 } from "@tscircuit/circuit-json-util";
|
|
71951
|
-
import { compose as
|
|
71951
|
+
import { compose as compose7, translate as translate7, scale as scale5 } from "transformation-matrix";
|
|
71952
71952
|
|
|
71953
71953
|
// node_modules/earcut/src/earcut.js
|
|
71954
71954
|
var steiners = new Set;
|
|
@@ -72522,7 +72522,7 @@ import {
|
|
|
72522
72522
|
Setup
|
|
72523
72523
|
} from "kicadts";
|
|
72524
72524
|
import { PcbNet } from "kicadts";
|
|
72525
|
-
import { Footprint as Footprint3, FootprintModel as FootprintModel4 } from "kicadts";
|
|
72525
|
+
import { Footprint as Footprint3, FootprintModel as FootprintModel4, FootprintAttr as FootprintAttr3 } from "kicadts";
|
|
72526
72526
|
import {
|
|
72527
72527
|
parseKicadSexpr,
|
|
72528
72528
|
KicadPcb,
|
|
@@ -72534,7 +72534,7 @@ import {
|
|
|
72534
72534
|
TextEffects as TextEffects8,
|
|
72535
72535
|
TextEffectsFont as TextEffectsFont8
|
|
72536
72536
|
} from "kicadts";
|
|
72537
|
-
import { applyToPoint as
|
|
72537
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
72538
72538
|
import {
|
|
72539
72539
|
Property as Property2,
|
|
72540
72540
|
TextEffects as TextEffects9,
|
|
@@ -72563,8 +72563,16 @@ import { applyToPoint as applyToPoint15, rotate as rotate4, identity as identity
|
|
|
72563
72563
|
import { TextEffectsJustify as TextEffectsJustify5 } from "kicadts";
|
|
72564
72564
|
import { FpLine, Stroke as Stroke11 } from "kicadts";
|
|
72565
72565
|
import { applyToPoint as applyToPoint16, identity as identity3, rotate as rotate5 } from "transformation-matrix";
|
|
72566
|
+
import { FpPoly as FpPoly2, Stroke as Stroke12 } from "kicadts";
|
|
72567
|
+
import {
|
|
72568
|
+
applyToPoint as applyToPoint17,
|
|
72569
|
+
compose as compose5,
|
|
72570
|
+
rotate as rotate6,
|
|
72571
|
+
scale as scale3,
|
|
72572
|
+
translate as translate5
|
|
72573
|
+
} from "transformation-matrix";
|
|
72566
72574
|
import { FpText as FpText3, TextEffects as TextEffects11, TextEffectsFont as TextEffectsFont11 } from "kicadts";
|
|
72567
|
-
import { applyToPoint as
|
|
72575
|
+
import { applyToPoint as applyToPoint18, rotate as rotate7, identity as identity4 } from "transformation-matrix";
|
|
72568
72576
|
import { FootprintModel as FootprintModel3 } from "kicadts";
|
|
72569
72577
|
import {
|
|
72570
72578
|
FootprintPad,
|
|
@@ -72576,24 +72584,24 @@ import {
|
|
|
72576
72584
|
PadNet
|
|
72577
72585
|
} from "kicadts";
|
|
72578
72586
|
import {
|
|
72579
|
-
applyToPoint as
|
|
72580
|
-
compose as
|
|
72581
|
-
translate as
|
|
72582
|
-
scale as
|
|
72583
|
-
rotate as
|
|
72587
|
+
applyToPoint as applyToPoint19,
|
|
72588
|
+
compose as compose6,
|
|
72589
|
+
translate as translate6,
|
|
72590
|
+
scale as scale4,
|
|
72591
|
+
rotate as rotate8
|
|
72584
72592
|
} from "transformation-matrix";
|
|
72585
72593
|
import { FootprintPad as FootprintPad2, PadDrill, PadNet as PadNet2 } from "kicadts";
|
|
72586
|
-
import { applyToPoint as
|
|
72594
|
+
import { applyToPoint as applyToPoint20, rotate as rotate9, identity as identity5 } from "transformation-matrix";
|
|
72587
72595
|
import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
|
|
72588
|
-
import { applyToPoint as
|
|
72589
|
-
import { FpLine as FpLine2, Stroke as
|
|
72590
|
-
import { applyToPoint as
|
|
72596
|
+
import { applyToPoint as applyToPoint21, rotate as rotate10, identity as identity6 } from "transformation-matrix";
|
|
72597
|
+
import { FpLine as FpLine2, Stroke as Stroke13 } from "kicadts";
|
|
72598
|
+
import { applyToPoint as applyToPoint22, identity as identity7, rotate as rotate11 } from "transformation-matrix";
|
|
72591
72599
|
import { Segment, SegmentNet } from "kicadts";
|
|
72592
|
-
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
72593
|
-
import { Via, ViaNet } from "kicadts";
|
|
72594
72600
|
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
72595
|
-
import {
|
|
72601
|
+
import { Via, ViaNet } from "kicadts";
|
|
72596
72602
|
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
72603
|
+
import { Footprint as Footprint4 } from "kicadts";
|
|
72604
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
72597
72605
|
import { GrLine } from "kicadts";
|
|
72598
72606
|
import {
|
|
72599
72607
|
At as At3,
|
|
@@ -72602,10 +72610,10 @@ import {
|
|
|
72602
72610
|
TextEffectsFont as TextEffectsFont12,
|
|
72603
72611
|
TextEffectsJustify as TextEffectsJustify6
|
|
72604
72612
|
} from "kicadts";
|
|
72605
|
-
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
72606
|
-
import { applyToPoint as applyToPoint28, rotate as rotate11 } from "transformation-matrix";
|
|
72607
|
-
import { GrText as GrText2, TextEffects as TextEffects13, TextEffectsFont as TextEffectsFont13, At as At4 } from "kicadts";
|
|
72608
72613
|
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
72614
|
+
import { applyToPoint as applyToPoint29, rotate as rotate12 } from "transformation-matrix";
|
|
72615
|
+
import { GrText as GrText2, TextEffects as TextEffects13, TextEffectsFont as TextEffectsFont13, At as At4 } from "kicadts";
|
|
72616
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
72609
72617
|
import { cju as cju3 } from "@tscircuit/circuit-json-util";
|
|
72610
72618
|
import { cju as cju4 } from "@tscircuit/circuit-json-util";
|
|
72611
72619
|
import { parseKicadSexpr as parseKicadSexpr2, KicadSch as KicadSch2 } from "kicadts";
|
|
@@ -73079,8 +73087,22 @@ function getReferenceDesignator(sourceComponent) {
|
|
|
73079
73087
|
const prefix = getReferencePrefixForComponent(sourceComponent);
|
|
73080
73088
|
return `${prefix}?`;
|
|
73081
73089
|
}
|
|
73090
|
+
var legacySymbolNameByOrientedSymbolName = {
|
|
73091
|
+
n_channel_e_mosfet_transistor_gate_left_drain_top: "n_channel_e_mosfet_transistor_horz",
|
|
73092
|
+
n_channel_e_mosfet_transistor_gate_top_drain_right: "n_channel_e_mosfet_transistor_vert",
|
|
73093
|
+
n_channel_d_mosfet_transistor_gate_left_drain_top: "n_channel_d_mosfet_transistor_horz",
|
|
73094
|
+
n_channel_d_mosfet_transistor_gate_top_drain_right: "n_channel_d_mosfet_transistor_vert",
|
|
73095
|
+
p_channel_e_mosfet_transistor_gate_left_drain_top: "p_channel_e_mosfet_transistor_horz",
|
|
73096
|
+
p_channel_e_mosfet_transistor_gate_top_drain_right: "p_channel_e_mosfet_transistor_vert",
|
|
73097
|
+
p_channel_d_mosfet_transistor_gate_left_drain_top: "p_channel_d_mosfet_transistor_horz",
|
|
73098
|
+
p_channel_d_mosfet_transistor_gate_top_drain_right: "p_channel_d_mosfet_transistor_vert"
|
|
73099
|
+
};
|
|
73100
|
+
var getSchematicSymbolData = (symbolName) => {
|
|
73101
|
+
const resolvedSymbolName = legacySymbolNameByOrientedSymbolName[symbolName] ?? symbolName;
|
|
73102
|
+
return symbols[resolvedSymbolName];
|
|
73103
|
+
};
|
|
73082
73104
|
function isBuiltinSymbol(symbolName) {
|
|
73083
|
-
return symbolName in
|
|
73105
|
+
return symbolName in symbols2;
|
|
73084
73106
|
}
|
|
73085
73107
|
function sanitizeLibraryIdentifierPart(value) {
|
|
73086
73108
|
return value.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "") || "connector";
|
|
@@ -73116,20 +73138,37 @@ function getLibraryId(sourceComp, schematicComp, cadComponent, schematicSymbolNa
|
|
|
73116
73138
|
function getComponentLevelLibraryId(sourceComp, schematicComp, cadComponent) {
|
|
73117
73139
|
return `${getLibraryId(sourceComp, schematicComp, cadComponent)}_${sanitizeLibraryIdentifierPart(schematicComp.schematic_component_id)}`;
|
|
73118
73140
|
}
|
|
73119
|
-
|
|
73120
|
-
|
|
73121
|
-
|
|
73122
|
-
|
|
73123
|
-
|
|
73124
|
-
|
|
73125
|
-
|
|
73126
|
-
|
|
73127
|
-
|
|
73128
|
-
|
|
73129
|
-
|
|
73130
|
-
|
|
73131
|
-
|
|
73132
|
-
|
|
73141
|
+
function isSchematicSymbolPrimitive(element) {
|
|
73142
|
+
return element.type === "schematic_arc" || element.type === "schematic_circle" || element.type === "schematic_line" || element.type === "schematic_path" || element.type === "schematic_rect";
|
|
73143
|
+
}
|
|
73144
|
+
function findLinkedSchematicSymbolId(circuitJson, schematicComponentId) {
|
|
73145
|
+
return circuitJson.find((element) => isSchematicSymbolPrimitive(element) && element.schematic_component_id === schematicComponentId && Boolean(element.schematic_symbol_id))?.schematic_symbol_id;
|
|
73146
|
+
}
|
|
73147
|
+
function resolveSchematicComponentSymbol({
|
|
73148
|
+
circuitJson,
|
|
73149
|
+
schematicComponent,
|
|
73150
|
+
sourceComponent,
|
|
73151
|
+
cadComponents
|
|
73152
|
+
}) {
|
|
73153
|
+
const cadComponent = cadComponents.find((candidate) => candidate.source_component_id === sourceComponent.source_component_id);
|
|
73154
|
+
const linkedSchematicSymbolId = findLinkedSchematicSymbolId(circuitJson, schematicComponent.schematic_component_id);
|
|
73155
|
+
const schematicSymbolId = schematicComponent.schematic_symbol_id || linkedSchematicSymbolId;
|
|
73156
|
+
const schematicSymbol = schematicSymbolId ? circuitJson.find((element) => element.type === "schematic_symbol" && element.schematic_symbol_id === schematicSymbolId) : undefined;
|
|
73157
|
+
const schematicSymbolName = schematicSymbolId ? schematicSymbol?.name ?? getKicadCompatibleCustomSymbolName(sourceComponent, cadComponent, schematicSymbolId) : undefined;
|
|
73158
|
+
const usesComponentLevelSymbolPrimitives = hasComponentLevelSymbolPrimitives(circuitJson, schematicComponent);
|
|
73159
|
+
const libraryId = usesComponentLevelSymbolPrimitives ? getComponentLevelLibraryId(sourceComponent, schematicComponent, cadComponent) : getLibraryId(sourceComponent, schematicComponent, cadComponent, schematicSymbolName);
|
|
73160
|
+
const isChip = sourceComponent.ftype === "simple_chip" || sourceComponent.ftype === "simple_pin_header" || sourceComponent.ftype === "simple_connector";
|
|
73161
|
+
return {
|
|
73162
|
+
cadComponent,
|
|
73163
|
+
schematicSymbol,
|
|
73164
|
+
schematicSymbolId,
|
|
73165
|
+
schematicSymbolName,
|
|
73166
|
+
hasLinkedSymbolPrimitives: Boolean(linkedSchematicSymbolId),
|
|
73167
|
+
usesComponentLevelSymbolPrimitives,
|
|
73168
|
+
libraryId,
|
|
73169
|
+
isChip
|
|
73170
|
+
};
|
|
73171
|
+
}
|
|
73133
73172
|
var normalizePositiveDegrees = (degrees) => (degrees % 360 + 360) % 360;
|
|
73134
73173
|
var getDirectedSweepDegrees = ({
|
|
73135
73174
|
startAngleDegrees,
|
|
@@ -73325,7 +73364,7 @@ function buildSymbolDataFromSchematicPrimitives(params2) {
|
|
|
73325
73364
|
function createArcFromPrimitive({
|
|
73326
73365
|
primitive,
|
|
73327
73366
|
transform,
|
|
73328
|
-
scale:
|
|
73367
|
+
scale: scale6
|
|
73329
73368
|
}) {
|
|
73330
73369
|
const start = applyToPoint(transform, primitive.start);
|
|
73331
73370
|
const mid = applyToPoint(transform, primitive.mid);
|
|
@@ -73338,7 +73377,7 @@ function createArcFromPrimitive({
|
|
|
73338
73377
|
"stroke",
|
|
73339
73378
|
[
|
|
73340
73379
|
"width",
|
|
73341
|
-
primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth *
|
|
73380
|
+
primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale6
|
|
73342
73381
|
],
|
|
73343
73382
|
["type", primitive.isDashed ? "dash" : "default"]
|
|
73344
73383
|
],
|
|
@@ -73392,7 +73431,7 @@ function createSymbolFillSexprPrimitives({
|
|
|
73392
73431
|
function createCircleFromPrimitive({
|
|
73393
73432
|
primitive,
|
|
73394
73433
|
transform,
|
|
73395
|
-
scale:
|
|
73434
|
+
scale: scale6
|
|
73396
73435
|
}) {
|
|
73397
73436
|
const scaledPos = applyToPoint2(transform, {
|
|
73398
73437
|
x: primitive.x,
|
|
@@ -73400,12 +73439,12 @@ function createCircleFromPrimitive({
|
|
|
73400
73439
|
});
|
|
73401
73440
|
return SymbolCircle.fromSexprPrimitives([
|
|
73402
73441
|
["center", scaledPos.x, scaledPos.y],
|
|
73403
|
-
["radius", primitive.radius *
|
|
73442
|
+
["radius", primitive.radius * scale6],
|
|
73404
73443
|
[
|
|
73405
73444
|
"stroke",
|
|
73406
73445
|
[
|
|
73407
73446
|
"width",
|
|
73408
|
-
primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth *
|
|
73447
|
+
primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale6
|
|
73409
73448
|
],
|
|
73410
73449
|
["type", "default"]
|
|
73411
73450
|
],
|
|
@@ -73427,7 +73466,7 @@ function createPolylineFromPoints({
|
|
|
73427
73466
|
fallbackFillType,
|
|
73428
73467
|
strokeWidth,
|
|
73429
73468
|
isDashed,
|
|
73430
|
-
scale:
|
|
73469
|
+
scale: scale6
|
|
73431
73470
|
}) {
|
|
73432
73471
|
const polyline = new SymbolPolyline;
|
|
73433
73472
|
const xyPoints = points.map((p) => {
|
|
@@ -73437,7 +73476,7 @@ function createPolylineFromPoints({
|
|
|
73437
73476
|
const pts = new Pts(xyPoints);
|
|
73438
73477
|
polyline.points = pts;
|
|
73439
73478
|
const stroke = new Stroke2;
|
|
73440
|
-
stroke.width = strokeWidth == null ? 0.254 : strokeWidth *
|
|
73479
|
+
stroke.width = strokeWidth == null ? 0.254 : strokeWidth * scale6;
|
|
73441
73480
|
stroke.type = isDashed ? "dash" : "default";
|
|
73442
73481
|
polyline.stroke = stroke;
|
|
73443
73482
|
const fill = SymbolPolylineFill.fromSexprPrimitives(createSymbolFillSexprPrimitives({
|
|
@@ -73451,7 +73490,7 @@ function createPolylineFromPoints({
|
|
|
73451
73490
|
function createRectangleFromPrimitive({
|
|
73452
73491
|
primitive,
|
|
73453
73492
|
transform,
|
|
73454
|
-
scale:
|
|
73493
|
+
scale: scale6
|
|
73455
73494
|
}) {
|
|
73456
73495
|
const start = applyToPoint4(transform, primitive.start);
|
|
73457
73496
|
const end = applyToPoint4(transform, primitive.end);
|
|
@@ -73462,7 +73501,7 @@ function createRectangleFromPrimitive({
|
|
|
73462
73501
|
"stroke",
|
|
73463
73502
|
[
|
|
73464
73503
|
"width",
|
|
73465
|
-
primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth *
|
|
73504
|
+
primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale6
|
|
73466
73505
|
],
|
|
73467
73506
|
["type", primitive.isDashed ? "dash" : "default"]
|
|
73468
73507
|
],
|
|
@@ -73478,13 +73517,13 @@ function createRectangleFromPrimitive({
|
|
|
73478
73517
|
function createTextFromPrimitive({
|
|
73479
73518
|
schText,
|
|
73480
73519
|
transform,
|
|
73481
|
-
scale:
|
|
73520
|
+
scale: scale6
|
|
73482
73521
|
}) {
|
|
73483
73522
|
const symbolText = new SymbolText;
|
|
73484
73523
|
const scaledPos = applyToPoint5(transform, { x: schText.x, y: schText.y });
|
|
73485
73524
|
symbolText.value = schText.text;
|
|
73486
73525
|
symbolText.at = [scaledPos.x, scaledPos.y, 0];
|
|
73487
|
-
const scaledFontSize = schText.fontSize *
|
|
73526
|
+
const scaledFontSize = schText.fontSize * scale6;
|
|
73488
73527
|
const font = new TextEffectsFont2;
|
|
73489
73528
|
font.size = { height: scaledFontSize, width: scaledFontSize };
|
|
73490
73529
|
symbolText.effects = new TextEffects2({ font });
|
|
@@ -73737,12 +73776,81 @@ function calculatePinPosition({
|
|
|
73737
73776
|
}
|
|
73738
73777
|
return { x, y, angle };
|
|
73739
73778
|
}
|
|
73779
|
+
function getPortSide(x, y) {
|
|
73780
|
+
if (Math.abs(x) > Math.abs(y))
|
|
73781
|
+
return x < 0 ? "left" : "right";
|
|
73782
|
+
return y < 0 ? "down" : "up";
|
|
73783
|
+
}
|
|
73784
|
+
function hasDuplicatePositions(values) {
|
|
73785
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
73786
|
+
return sorted.some((value, index) => {
|
|
73787
|
+
const previous = sorted[index - 1];
|
|
73788
|
+
return previous !== undefined && Math.abs(value - previous) < 0.000001;
|
|
73789
|
+
});
|
|
73790
|
+
}
|
|
73791
|
+
function getCircuitPinNumbers({
|
|
73792
|
+
symbolData,
|
|
73793
|
+
schematicComponent,
|
|
73794
|
+
schematicPorts,
|
|
73795
|
+
sourcePorts
|
|
73796
|
+
}) {
|
|
73797
|
+
const matches = /* @__PURE__ */ new Map;
|
|
73798
|
+
if (!schematicComponent)
|
|
73799
|
+
return matches;
|
|
73800
|
+
const sourcePortsById = new Map(sourcePorts.map((port) => [port.source_port_id, port]));
|
|
73801
|
+
const symbolCenter = symbolData.center ?? { x: 0, y: 0 };
|
|
73802
|
+
const componentPorts = schematicPorts.filter((port) => port.schematic_component_id === schematicComponent.schematic_component_id);
|
|
73803
|
+
for (const side of ["left", "right", "up", "down"]) {
|
|
73804
|
+
const symbolPorts = symbolData.ports.map((port, index) => ({
|
|
73805
|
+
index,
|
|
73806
|
+
x: (port.x ?? 0) - symbolCenter.x,
|
|
73807
|
+
y: (port.y ?? 0) - symbolCenter.y
|
|
73808
|
+
})).filter((port) => getPortSide(port.x, port.y) === side);
|
|
73809
|
+
const circuitPorts = componentPorts.map((port) => ({
|
|
73810
|
+
port,
|
|
73811
|
+
x: port.center.x - schematicComponent.center.x,
|
|
73812
|
+
y: port.center.y - schematicComponent.center.y
|
|
73813
|
+
})).filter(({ port, x, y }) => (port.facing_direction ?? getPortSide(x, y)) === side);
|
|
73814
|
+
if (symbolPorts.length === 0 || symbolPorts.length !== circuitPorts.length) {
|
|
73815
|
+
continue;
|
|
73816
|
+
}
|
|
73817
|
+
const coordinate = (port) => side === "left" || side === "right" ? port.y : port.x;
|
|
73818
|
+
if (hasDuplicatePositions(symbolPorts.map(coordinate)) || hasDuplicatePositions(circuitPorts.map(coordinate))) {
|
|
73819
|
+
continue;
|
|
73820
|
+
}
|
|
73821
|
+
symbolPorts.sort((a, b) => coordinate(a) - coordinate(b));
|
|
73822
|
+
circuitPorts.sort((a, b) => coordinate(a) - coordinate(b));
|
|
73823
|
+
for (let index = 0;index < symbolPorts.length; index++) {
|
|
73824
|
+
const symbolPort = symbolPorts[index];
|
|
73825
|
+
const circuitPort = circuitPorts[index];
|
|
73826
|
+
if (!symbolPort || !circuitPort)
|
|
73827
|
+
continue;
|
|
73828
|
+
const pinNumber = circuitPort.port.pin_number ?? (circuitPort.port.source_port_id ? sourcePortsById.get(circuitPort.port.source_port_id)?.pin_number : undefined);
|
|
73829
|
+
if (pinNumber !== undefined && pinNumber !== null) {
|
|
73830
|
+
matches.set(symbolPort.index, String(pinNumber));
|
|
73831
|
+
}
|
|
73832
|
+
}
|
|
73833
|
+
}
|
|
73834
|
+
return matches;
|
|
73835
|
+
}
|
|
73836
|
+
function validateInferredPinNumbers(symbolData, inferredPinNumbers) {
|
|
73837
|
+
const missingPinIndices = symbolData.ports.map((port, index) => port.pinNumber == null ? index : undefined).filter((index) => index !== undefined);
|
|
73838
|
+
if (missingPinIndices.length === 0 || missingPinIndices.some((index) => !inferredPinNumbers.has(index))) {
|
|
73839
|
+
return /* @__PURE__ */ new Map;
|
|
73840
|
+
}
|
|
73841
|
+
const resolvedPinNumbers = symbolData.ports.map((port, index) => port.pinNumber?.toString() ?? inferredPinNumbers.get(index));
|
|
73842
|
+
if (resolvedPinNumbers.some((pinNumber) => pinNumber === undefined) || new Set(resolvedPinNumbers).size !== resolvedPinNumbers.length) {
|
|
73843
|
+
return /* @__PURE__ */ new Map;
|
|
73844
|
+
}
|
|
73845
|
+
return inferredPinNumbers;
|
|
73846
|
+
}
|
|
73740
73847
|
function createPinSubsymbol({
|
|
73741
73848
|
libId,
|
|
73742
73849
|
symbolData,
|
|
73743
73850
|
isChip,
|
|
73744
73851
|
schematicComponent,
|
|
73745
73852
|
schematicPorts,
|
|
73853
|
+
sourcePorts,
|
|
73746
73854
|
c2kMatSchScale
|
|
73747
73855
|
}) {
|
|
73748
73856
|
const pinSymbol = new SchematicSymbol3({
|
|
@@ -73750,8 +73858,14 @@ function createPinSubsymbol({
|
|
|
73750
73858
|
});
|
|
73751
73859
|
const CHIP_PIN_LENGTH = 6;
|
|
73752
73860
|
const CUSTOM_SYMBOL_PIN_LENGTH = 0.01;
|
|
73753
|
-
|
|
73754
|
-
|
|
73861
|
+
const inferredPinNumbers = isChip ? /* @__PURE__ */ new Map : getCircuitPinNumbers({
|
|
73862
|
+
symbolData,
|
|
73863
|
+
schematicComponent,
|
|
73864
|
+
schematicPorts,
|
|
73865
|
+
sourcePorts
|
|
73866
|
+
});
|
|
73867
|
+
const circuitPinNumbers = validateInferredPinNumbers(symbolData, inferredPinNumbers);
|
|
73868
|
+
for (const [i, port] of symbolData.ports.entries()) {
|
|
73755
73869
|
const pin = new SymbolPin;
|
|
73756
73870
|
pin.pinElectricalType = "passive";
|
|
73757
73871
|
pin.pinGraphicStyle = "line";
|
|
@@ -73775,7 +73889,7 @@ function createPinSubsymbol({
|
|
|
73775
73889
|
const numFont = new TextEffectsFont4;
|
|
73776
73890
|
numFont.size = { height: 1.27, width: 1.27 };
|
|
73777
73891
|
const numEffects = new TextEffects4({ font: numFont });
|
|
73778
|
-
const pinNum = port.pinNumber?.toString()
|
|
73892
|
+
const pinNum = port.pinNumber?.toString() ?? circuitPinNumbers.get(i) ?? `${i + 1}`;
|
|
73779
73893
|
pin._sxNumber = new SymbolPinNumber({
|
|
73780
73894
|
value: pinNum,
|
|
73781
73895
|
effects: numEffects
|
|
@@ -73827,19 +73941,23 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
73827
73941
|
const sourceComp = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
|
|
73828
73942
|
if (!sourceComp)
|
|
73829
73943
|
return null;
|
|
73830
|
-
const
|
|
73831
|
-
|
|
73832
|
-
|
|
73833
|
-
|
|
73834
|
-
|
|
73835
|
-
|
|
73836
|
-
|
|
73837
|
-
|
|
73944
|
+
const symbolContext = resolveSchematicComponentSymbol({
|
|
73945
|
+
circuitJson: this.ctx.circuitJson,
|
|
73946
|
+
schematicComponent,
|
|
73947
|
+
sourceComponent: sourceComp,
|
|
73948
|
+
cadComponents: db.cad_component?.list?.() ?? []
|
|
73949
|
+
});
|
|
73950
|
+
const {
|
|
73951
|
+
cadComponent,
|
|
73952
|
+
schematicSymbolId,
|
|
73953
|
+
usesComponentLevelSymbolPrimitives,
|
|
73954
|
+
libraryId,
|
|
73955
|
+
isChip
|
|
73956
|
+
} = symbolContext;
|
|
73838
73957
|
if (schematicSymbolId) {
|
|
73839
|
-
return this.createLibrarySymbolFromSchematicSymbol(schematicComponent, sourceComp,
|
|
73958
|
+
return this.createLibrarySymbolFromSchematicSymbol(schematicComponent, sourceComp, symbolContext);
|
|
73840
73959
|
}
|
|
73841
|
-
|
|
73842
|
-
if (hasInnerSymbolPrimitives) {
|
|
73960
|
+
if (usesComponentLevelSymbolPrimitives) {
|
|
73843
73961
|
const innerSymbolData = buildSymbolDataFromSchematicPrimitives({
|
|
73844
73962
|
circuitJson: this.ctx.circuitJson,
|
|
73845
73963
|
schematicComponentId: schematicComponent.schematic_component_id,
|
|
@@ -73855,14 +73973,13 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
73855
73973
|
...innerSymbolData,
|
|
73856
73974
|
texts: []
|
|
73857
73975
|
};
|
|
73858
|
-
const libId2 = getComponentLevelLibraryId(sourceComp, schematicComponent, cadComponent);
|
|
73859
73976
|
const footprintName2 = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
73860
73977
|
let footprintRef = "";
|
|
73861
73978
|
if (footprintName2) {
|
|
73862
73979
|
footprintRef = `tscircuit:${footprintName2}`;
|
|
73863
73980
|
}
|
|
73864
73981
|
return this.createLibrarySymbol({
|
|
73865
|
-
libId:
|
|
73982
|
+
libId: libraryId,
|
|
73866
73983
|
symbolData: symbolData2,
|
|
73867
73984
|
isChip: false,
|
|
73868
73985
|
hidePinNames: true,
|
|
@@ -73882,11 +73999,9 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
73882
73999
|
const symbolData = this.getSymbolData(symbolName, schematicComponent);
|
|
73883
74000
|
if (!symbolData)
|
|
73884
74001
|
return null;
|
|
73885
|
-
const libId = getLibraryId(sourceComp, schematicComponent, cadComponent);
|
|
73886
|
-
const isChip = sourceComp.ftype === "simple_chip" || sourceComp.ftype === "simple_pin_header" || sourceComp.ftype === "simple_connector";
|
|
73887
74002
|
const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
73888
74003
|
return this.createLibrarySymbol({
|
|
73889
|
-
libId,
|
|
74004
|
+
libId: libraryId,
|
|
73890
74005
|
symbolData,
|
|
73891
74006
|
isChip,
|
|
73892
74007
|
schematicComponent,
|
|
@@ -73898,23 +74013,15 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
73898
74013
|
symbolScale: this.ctx.kicadSchematicScaleFactor
|
|
73899
74014
|
});
|
|
73900
74015
|
}
|
|
73901
|
-
createLibrarySymbolFromSchematicSymbol(schematicComponent, sourceComp,
|
|
73902
|
-
const {
|
|
73903
|
-
|
|
73904
|
-
if (!schematicSymbol) {
|
|
74016
|
+
createLibrarySymbolFromSchematicSymbol(schematicComponent, sourceComp, symbolContext) {
|
|
74017
|
+
const { cadComponent, schematicSymbol, schematicSymbolId, libraryId } = symbolContext;
|
|
74018
|
+
if (!schematicSymbol || !schematicSymbolId) {
|
|
73905
74019
|
return null;
|
|
73906
74020
|
}
|
|
73907
|
-
|
|
73908
|
-
if (schematicSymbol.name) {
|
|
73909
|
-
symbolName = schematicSymbol.name;
|
|
73910
|
-
} else {
|
|
73911
|
-
symbolName = getKicadCompatibleCustomSymbolName(sourceComp, cadComponent, schematicSymbolId);
|
|
73912
|
-
}
|
|
73913
|
-
const libId = `Custom:${symbolName}`;
|
|
73914
|
-
if (this.processedSymbolNames.has(libId)) {
|
|
74021
|
+
if (this.processedSymbolNames.has(libraryId)) {
|
|
73915
74022
|
return null;
|
|
73916
74023
|
}
|
|
73917
|
-
this.processedSymbolNames.add(
|
|
74024
|
+
this.processedSymbolNames.add(libraryId);
|
|
73918
74025
|
const symbolData = buildSymbolDataFromSchematicPrimitives({
|
|
73919
74026
|
circuitJson: this.ctx.circuitJson,
|
|
73920
74027
|
schematicSymbolId,
|
|
@@ -73925,7 +74032,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
73925
74032
|
});
|
|
73926
74033
|
const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
73927
74034
|
return this.createLibrarySymbol({
|
|
73928
|
-
libId,
|
|
74035
|
+
libId: libraryId,
|
|
73929
74036
|
symbolData,
|
|
73930
74037
|
isChip: false,
|
|
73931
74038
|
schematicComponent,
|
|
@@ -74016,6 +74123,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
74016
74123
|
isChip,
|
|
74017
74124
|
schematicComponent,
|
|
74018
74125
|
schematicPorts: this.ctx.db.schematic_port.list(),
|
|
74126
|
+
sourcePorts: this.ctx.db.source_port.list(),
|
|
74019
74127
|
c2kMatSchScale: symbolScale
|
|
74020
74128
|
});
|
|
74021
74129
|
symbol.subSymbols.push(pinSymbol);
|
|
@@ -74482,6 +74590,19 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
74482
74590
|
const sourceComponent = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
|
|
74483
74591
|
if (!sourceComponent)
|
|
74484
74592
|
continue;
|
|
74593
|
+
const symbolContext = resolveSchematicComponentSymbol({
|
|
74594
|
+
circuitJson: this.ctx.circuitJson,
|
|
74595
|
+
schematicComponent,
|
|
74596
|
+
sourceComponent,
|
|
74597
|
+
cadComponents: db.cad_component?.list?.() ?? []
|
|
74598
|
+
});
|
|
74599
|
+
const {
|
|
74600
|
+
schematicSymbol,
|
|
74601
|
+
schematicSymbolId,
|
|
74602
|
+
hasLinkedSymbolPrimitives,
|
|
74603
|
+
usesComponentLevelSymbolPrimitives,
|
|
74604
|
+
libraryId
|
|
74605
|
+
} = symbolContext;
|
|
74485
74606
|
if (!this.ctx.c2kMatSch)
|
|
74486
74607
|
continue;
|
|
74487
74608
|
const { x, y } = applyToPoint9(this.ctx.c2kMatSch, {
|
|
@@ -74499,42 +74620,18 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
74499
74620
|
uuid,
|
|
74500
74621
|
fieldsAutoplaced: false
|
|
74501
74622
|
});
|
|
74502
|
-
const
|
|
74503
|
-
let schematicSymbolName;
|
|
74504
|
-
let schematicSymbolId = schematicComponent.schematic_symbol_id;
|
|
74505
|
-
if (!schematicSymbolId) {
|
|
74506
|
-
const linkedPrimitive = this.ctx.circuitJson.find((el) => (el.type === "schematic_line" || el.type === "schematic_circle" || el.type === "schematic_arc" || el.type === "schematic_path" || el.type === "schematic_rect") && el.schematic_component_id === schematicComponent.schematic_component_id && el.schematic_symbol_id);
|
|
74507
|
-
if (linkedPrimitive) {
|
|
74508
|
-
schematicSymbolId = linkedPrimitive.schematic_symbol_id;
|
|
74509
|
-
}
|
|
74510
|
-
}
|
|
74511
|
-
if (schematicSymbolId) {
|
|
74512
|
-
const schematicSymbol = this.ctx.circuitJson.find((el) => el.type === "schematic_symbol" && el.schematic_symbol_id === schematicSymbolId);
|
|
74513
|
-
if (schematicSymbol?.name) {
|
|
74514
|
-
schematicSymbolName = schematicSymbol.name;
|
|
74515
|
-
} else {
|
|
74516
|
-
schematicSymbolName = getKicadCompatibleCustomSymbolName(sourceComponent, cadComponent, schematicSymbolId);
|
|
74517
|
-
}
|
|
74518
|
-
}
|
|
74519
|
-
const usesComponentLevelSymbolPrimitives = hasComponentLevelSymbolPrimitives(this.ctx.circuitJson, schematicComponent);
|
|
74520
|
-
const libId = usesComponentLevelSymbolPrimitives ? getComponentLevelLibraryId(sourceComponent, schematicComponent, cadComponent) : getLibraryId(sourceComponent, schematicComponent, cadComponent, schematicSymbolName);
|
|
74521
|
-
const symLibId = new SymbolLibId2(libId);
|
|
74623
|
+
const symLibId = new SymbolLibId2(libraryId);
|
|
74522
74624
|
symbol._sxLibId = symLibId;
|
|
74523
74625
|
const { reference, value, description } = this.getComponentMetadata(sourceComponent);
|
|
74524
74626
|
const hasManufacturerValueForValuePlacement = (sourceComponent.ftype === "simple_chip" || sourceComponent.ftype === "simple_connector") && Boolean(sourceComponent.manufacturer_part_number);
|
|
74525
74627
|
const { refTextPos, valTextPos, refJustify, valJustify } = this.getTextPositions({
|
|
74526
74628
|
schematicComponent,
|
|
74527
74629
|
placeValueAtNamePosition: hasManufacturerValueForValuePlacement,
|
|
74630
|
+
isCustomSymbol: hasLinkedSymbolPrimitives,
|
|
74528
74631
|
reference,
|
|
74529
74632
|
value
|
|
74530
74633
|
});
|
|
74531
|
-
|
|
74532
|
-
if (schematicSymbolId) {
|
|
74533
|
-
const schSymEl = this.ctx.circuitJson.find((el) => el.type === "schematic_symbol" && el.schematic_symbol_id === schematicSymbolId);
|
|
74534
|
-
if (schSymEl && schSymEl.type === "schematic_symbol") {
|
|
74535
|
-
symbolMetadata = schSymEl.metadata?.kicad_symbol;
|
|
74536
|
-
}
|
|
74537
|
-
}
|
|
74634
|
+
const symbolMetadata = schematicSymbol?.metadata?.kicad_symbol;
|
|
74538
74635
|
const refMeta = symbolMetadata?.properties?.Reference;
|
|
74539
74636
|
const hideGeneratedCustomReference = Boolean(schematicSymbolId) || usesComponentLevelSymbolPrimitives;
|
|
74540
74637
|
const referenceProperty = new SymbolProperty3({
|
|
@@ -74680,6 +74777,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
74680
74777
|
getTextPositions({
|
|
74681
74778
|
schematicComponent,
|
|
74682
74779
|
placeValueAtNamePosition,
|
|
74780
|
+
isCustomSymbol,
|
|
74683
74781
|
reference,
|
|
74684
74782
|
value
|
|
74685
74783
|
}) {
|
|
@@ -74695,7 +74793,6 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
74695
74793
|
const componentHeightMm = Math.abs(bodyEdge.y - symbolKicadPos.y) * 2;
|
|
74696
74794
|
const referenceAboveBodyY = symbolKicadPos.y - componentHeightMm / 2 - 3;
|
|
74697
74795
|
const valueBelowBodyY = symbolKicadPos.y + componentHeightMm / 2 + 3;
|
|
74698
|
-
const isCustomSymbol = this.isCustomSymbolComponent(schematicComponent);
|
|
74699
74796
|
if (isCustomSymbol) {
|
|
74700
74797
|
const customHeightMm = (schematicComponent.size?.height || 1) * this.ctx.kicadSchematicScaleFactor;
|
|
74701
74798
|
const refTextPos2 = {
|
|
@@ -74795,12 +74892,6 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
74795
74892
|
justify: getTextJustificationFromAnchor(text.anchor)
|
|
74796
74893
|
};
|
|
74797
74894
|
}
|
|
74798
|
-
isCustomSymbolComponent(schematicComponent) {
|
|
74799
|
-
const componentId = schematicComponent.schematic_component_id;
|
|
74800
|
-
if (!componentId)
|
|
74801
|
-
return false;
|
|
74802
|
-
return this.ctx.circuitJson.some((el) => (el.type === "schematic_line" || el.type === "schematic_circle" || el.type === "schematic_arc" || el.type === "schematic_path" || el.type === "schematic_rect") && el.schematic_component_id === componentId && el.schematic_symbol_id);
|
|
74803
|
-
}
|
|
74804
74895
|
getComponentMetadata(sourceComp) {
|
|
74805
74896
|
const name = sourceComp.name || "?";
|
|
74806
74897
|
const reference = getReferenceDesignator(sourceComp);
|
|
@@ -75616,7 +75707,7 @@ var InitializePcbStage = class extends ConverterStage {
|
|
|
75616
75707
|
paper.size = "A4";
|
|
75617
75708
|
kicadPcb.paper = paper;
|
|
75618
75709
|
const general = new PcbGeneral;
|
|
75619
|
-
general.thickness = 1.6;
|
|
75710
|
+
general.thickness = pcbBoard?.thickness ?? 1.6;
|
|
75620
75711
|
kicadPcb.general = general;
|
|
75621
75712
|
const setup = new Setup;
|
|
75622
75713
|
setup.padToMaskClearance = 0;
|
|
@@ -76006,6 +76097,17 @@ function applyMetadataToFootprint({
|
|
|
76006
76097
|
effects: createTextEffects2(),
|
|
76007
76098
|
hidden: true
|
|
76008
76099
|
}));
|
|
76100
|
+
if (componentProperty.manufacturerPartNumber) {
|
|
76101
|
+
newProperties.push(new Property2({
|
|
76102
|
+
key: "MPN",
|
|
76103
|
+
value: componentProperty.manufacturerPartNumber,
|
|
76104
|
+
position: [0, 0, 0],
|
|
76105
|
+
layer: "F.Fab",
|
|
76106
|
+
uuid: generateDeterministicUuid(`${componentProperty.reference}-property-MPN`),
|
|
76107
|
+
effects: createTextEffects2(),
|
|
76108
|
+
hidden: true
|
|
76109
|
+
}));
|
|
76110
|
+
}
|
|
76009
76111
|
footprint.properties = newProperties;
|
|
76010
76112
|
if (metadata?.attributes) {
|
|
76011
76113
|
if (!footprint.attr) {
|
|
@@ -76067,12 +76169,14 @@ function getkicadComponentProperty(sourceComp) {
|
|
|
76067
76169
|
const name = sourceComp.name || "?";
|
|
76068
76170
|
const reference = getReferenceDesignator(sourceComp);
|
|
76069
76171
|
const supplierPartNumber = getJlcpcbSupplierPartNumber(sourceComp);
|
|
76172
|
+
const manufacturerPartNumber = sourceComp.manufacturer_part_number;
|
|
76070
76173
|
if (sourceComp.ftype === "simple_resistor") {
|
|
76071
76174
|
const resistor = sourceComp;
|
|
76072
76175
|
return {
|
|
76073
76176
|
reference,
|
|
76074
76177
|
kicadComponentValue: resistor.display_resistance || "R",
|
|
76075
|
-
supplierPartNumber
|
|
76178
|
+
supplierPartNumber,
|
|
76179
|
+
manufacturerPartNumber
|
|
76076
76180
|
};
|
|
76077
76181
|
}
|
|
76078
76182
|
if (sourceComp.ftype === "simple_capacitor") {
|
|
@@ -76080,7 +76184,8 @@ function getkicadComponentProperty(sourceComp) {
|
|
|
76080
76184
|
return {
|
|
76081
76185
|
reference,
|
|
76082
76186
|
kicadComponentValue: capacitor.display_capacitance || "C",
|
|
76083
|
-
supplierPartNumber
|
|
76187
|
+
supplierPartNumber,
|
|
76188
|
+
manufacturerPartNumber
|
|
76084
76189
|
};
|
|
76085
76190
|
}
|
|
76086
76191
|
if (sourceComp.ftype === "simple_inductor") {
|
|
@@ -76088,35 +76193,40 @@ function getkicadComponentProperty(sourceComp) {
|
|
|
76088
76193
|
return {
|
|
76089
76194
|
reference,
|
|
76090
76195
|
kicadComponentValue: inductor.display_inductance || "L",
|
|
76091
|
-
supplierPartNumber
|
|
76196
|
+
supplierPartNumber,
|
|
76197
|
+
manufacturerPartNumber
|
|
76092
76198
|
};
|
|
76093
76199
|
}
|
|
76094
76200
|
if (sourceComp.ftype === "simple_diode") {
|
|
76095
76201
|
return {
|
|
76096
76202
|
reference,
|
|
76097
76203
|
kicadComponentValue: "D",
|
|
76098
|
-
supplierPartNumber
|
|
76204
|
+
supplierPartNumber,
|
|
76205
|
+
manufacturerPartNumber
|
|
76099
76206
|
};
|
|
76100
76207
|
}
|
|
76101
76208
|
if (sourceComp.ftype === "simple_chip") {
|
|
76102
76209
|
return {
|
|
76103
76210
|
reference,
|
|
76104
76211
|
kicadComponentValue: sourceComp?.manufacturer_part_number,
|
|
76105
|
-
supplierPartNumber
|
|
76212
|
+
supplierPartNumber,
|
|
76213
|
+
manufacturerPartNumber
|
|
76106
76214
|
};
|
|
76107
76215
|
}
|
|
76108
76216
|
if (sourceComp.ftype === "simple_led") {
|
|
76109
76217
|
return {
|
|
76110
76218
|
reference,
|
|
76111
76219
|
kicadComponentValue: sourceComp.manufacturer_part_number || "LED",
|
|
76112
|
-
supplierPartNumber
|
|
76220
|
+
supplierPartNumber,
|
|
76221
|
+
manufacturerPartNumber
|
|
76113
76222
|
};
|
|
76114
76223
|
}
|
|
76115
76224
|
if (sourceComp.ftype === "simple_switch") {
|
|
76116
76225
|
return {
|
|
76117
76226
|
reference,
|
|
76118
76227
|
kicadComponentValue: sourceComp.manufacturer_part_number || "SW",
|
|
76119
|
-
supplierPartNumber
|
|
76228
|
+
supplierPartNumber,
|
|
76229
|
+
manufacturerPartNumber
|
|
76120
76230
|
};
|
|
76121
76231
|
}
|
|
76122
76232
|
if (sourceComp.ftype === "simple_potentiometer") {
|
|
@@ -76124,13 +76234,15 @@ function getkicadComponentProperty(sourceComp) {
|
|
|
76124
76234
|
return {
|
|
76125
76235
|
reference,
|
|
76126
76236
|
kicadComponentValue: potentiometer.display_max_resistance || "POT",
|
|
76127
|
-
supplierPartNumber
|
|
76237
|
+
supplierPartNumber,
|
|
76238
|
+
manufacturerPartNumber
|
|
76128
76239
|
};
|
|
76129
76240
|
}
|
|
76130
76241
|
return {
|
|
76131
76242
|
reference,
|
|
76132
76243
|
kicadComponentValue: name,
|
|
76133
|
-
supplierPartNumber
|
|
76244
|
+
supplierPartNumber,
|
|
76245
|
+
manufacturerPartNumber
|
|
76134
76246
|
};
|
|
76135
76247
|
}
|
|
76136
76248
|
function convertSilkscreenCircles(silkscreenCircles, { componentCenter, componentRotation = 0 }) {
|
|
@@ -76363,6 +76475,7 @@ function createFpTextFromCircuitJson({
|
|
|
76363
76475
|
bottom: "B.SilkS"
|
|
76364
76476
|
};
|
|
76365
76477
|
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
76478
|
+
const kicadLayerNames = textElement.is_knockout ? [kicadLayer, "knockout"] : kicadLayer;
|
|
76366
76479
|
const font = new TextEffectsFont10;
|
|
76367
76480
|
font.size = {
|
|
76368
76481
|
width: textElement.font_size || 1,
|
|
@@ -76387,7 +76500,7 @@ function createFpTextFromCircuitJson({
|
|
|
76387
76500
|
y: relativePosition.y,
|
|
76388
76501
|
angle: rotation
|
|
76389
76502
|
},
|
|
76390
|
-
layer:
|
|
76503
|
+
layer: kicadLayerNames,
|
|
76391
76504
|
effects: textEffects
|
|
76392
76505
|
});
|
|
76393
76506
|
}
|
|
@@ -76453,14 +76566,68 @@ function convertSilkscreenPaths(silkscreenPaths, { componentCenter, componentRot
|
|
|
76453
76566
|
}
|
|
76454
76567
|
return fpLines;
|
|
76455
76568
|
}
|
|
76569
|
+
var getRectanglePoints = (rect) => {
|
|
76570
|
+
const halfWidth = rect.width / 2;
|
|
76571
|
+
const halfHeight = rect.height / 2;
|
|
76572
|
+
const radius = Math.min(Math.max(rect.corner_radius ?? 0, 0), halfWidth, halfHeight);
|
|
76573
|
+
if (radius === 0) {
|
|
76574
|
+
return [
|
|
76575
|
+
{ x: -halfWidth, y: -halfHeight },
|
|
76576
|
+
{ x: halfWidth, y: -halfHeight },
|
|
76577
|
+
{ x: halfWidth, y: halfHeight },
|
|
76578
|
+
{ x: -halfWidth, y: halfHeight }
|
|
76579
|
+
];
|
|
76580
|
+
}
|
|
76581
|
+
const corners = [
|
|
76582
|
+
{ x: halfWidth - radius, y: halfHeight - radius, start: 0 },
|
|
76583
|
+
{ x: -halfWidth + radius, y: halfHeight - radius, start: 90 },
|
|
76584
|
+
{ x: -halfWidth + radius, y: -halfHeight + radius, start: 180 },
|
|
76585
|
+
{ x: halfWidth - radius, y: -halfHeight + radius, start: 270 }
|
|
76586
|
+
];
|
|
76587
|
+
return corners.flatMap((corner) => Array.from({ length: 9 }, (_, index) => {
|
|
76588
|
+
const angle = (corner.start + index * 90 / 8) * Math.PI / 180;
|
|
76589
|
+
return {
|
|
76590
|
+
x: corner.x + radius * Math.cos(angle),
|
|
76591
|
+
y: corner.y + radius * Math.sin(angle)
|
|
76592
|
+
};
|
|
76593
|
+
}));
|
|
76594
|
+
};
|
|
76595
|
+
function convertSilkscreenRects({
|
|
76596
|
+
silkscreenRects,
|
|
76597
|
+
componentCenter,
|
|
76598
|
+
componentRotation = 0
|
|
76599
|
+
}) {
|
|
76600
|
+
const toLocal = compose5(rotate6(componentRotation * Math.PI / 180), scale3(1, -1), translate5(-componentCenter.x, -componentCenter.y));
|
|
76601
|
+
return silkscreenRects.flatMap((rect) => {
|
|
76602
|
+
const hasStroke = rect.has_stroke ?? rect.stroke_width > 0;
|
|
76603
|
+
if (!hasStroke && !rect.is_filled)
|
|
76604
|
+
return [];
|
|
76605
|
+
const fromRectCenter = compose5(translate5(rect.center.x, rect.center.y), rotate6((rect.ccw_rotation ?? 0) * Math.PI / 180));
|
|
76606
|
+
const points = getRectanglePoints(rect).map((point) => applyToPoint17(toLocal, applyToPoint17(fromRectCenter, point)));
|
|
76607
|
+
const stroke = hasStroke ? new Stroke12 : undefined;
|
|
76608
|
+
if (stroke) {
|
|
76609
|
+
stroke.width = rect.stroke_width;
|
|
76610
|
+
stroke.type = rect.is_stroke_dashed ? "dash" : "default";
|
|
76611
|
+
}
|
|
76612
|
+
return [
|
|
76613
|
+
new FpPoly2({
|
|
76614
|
+
points,
|
|
76615
|
+
layer: rect.layer === "bottom" ? "B.SilkS" : "F.SilkS",
|
|
76616
|
+
stroke,
|
|
76617
|
+
fill: rect.is_filled ?? false,
|
|
76618
|
+
uuid: generateDeterministicUuid(rect.pcb_silkscreen_rect_id)
|
|
76619
|
+
})
|
|
76620
|
+
];
|
|
76621
|
+
});
|
|
76622
|
+
}
|
|
76456
76623
|
function convertNoteTexts(params2) {
|
|
76457
76624
|
const { noteTexts, componentCenter, componentRotation } = params2;
|
|
76458
76625
|
const fpTexts = [];
|
|
76459
76626
|
for (const textElement of noteTexts) {
|
|
76460
76627
|
const relX = textElement.anchor_position.x - componentCenter.x;
|
|
76461
76628
|
const relY = -(textElement.anchor_position.y - componentCenter.y);
|
|
76462
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
76463
|
-
const rotatedPos =
|
|
76629
|
+
const rotationMatrix = componentRotation !== 0 ? rotate7(componentRotation * Math.PI / 180) : identity4();
|
|
76630
|
+
const rotatedPos = applyToPoint18(rotationMatrix, { x: relX, y: relY });
|
|
76464
76631
|
const fontSize = textElement.font_size || 1;
|
|
76465
76632
|
const font = new TextEffectsFont11;
|
|
76466
76633
|
font.size = { width: fontSize, height: fontSize };
|
|
@@ -76574,8 +76741,8 @@ function create3DModelsFromCadComponent(cadComponent, componentCenter, options)
|
|
|
76574
76741
|
model.offset = transform.offset;
|
|
76575
76742
|
model.rotate = transform.rotation;
|
|
76576
76743
|
if (cadComponent.model_unit_to_mm_scale_factor) {
|
|
76577
|
-
const
|
|
76578
|
-
model.scale = { x:
|
|
76744
|
+
const scale6 = cadComponent.model_unit_to_mm_scale_factor;
|
|
76745
|
+
model.scale = { x: scale6, y: scale6, z: scale6 };
|
|
76579
76746
|
}
|
|
76580
76747
|
models.push(model);
|
|
76581
76748
|
return models;
|
|
@@ -76600,8 +76767,8 @@ function createSmdPadFromCircuitJson({
|
|
|
76600
76767
|
} else {
|
|
76601
76768
|
throw new Error("Pad must have either x/y coordinates or points array");
|
|
76602
76769
|
}
|
|
76603
|
-
const cj2kicadMatrix =
|
|
76604
|
-
const rotatedPos =
|
|
76770
|
+
const cj2kicadMatrix = compose6(componentRotation !== 0 ? rotate8(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale4(1, -1), translate6(-componentCenter.x, -componentCenter.y));
|
|
76771
|
+
const rotatedPos = applyToPoint19(cj2kicadMatrix, {
|
|
76605
76772
|
x: padX,
|
|
76606
76773
|
y: padY
|
|
76607
76774
|
});
|
|
@@ -76624,9 +76791,9 @@ function createSmdPadFromCircuitJson({
|
|
|
76624
76791
|
];
|
|
76625
76792
|
} else if (pcbPad.shape === "polygon" && "points" in pcbPad) {
|
|
76626
76793
|
const points = pcbPad.points;
|
|
76627
|
-
const pointTransformMatrix =
|
|
76794
|
+
const pointTransformMatrix = compose6(scale4(1, -1), translate6(-padX, -padY));
|
|
76628
76795
|
const relativePoints = points.map((p) => {
|
|
76629
|
-
const transformed =
|
|
76796
|
+
const transformed = applyToPoint19(pointTransformMatrix, { x: p.x, y: p.y });
|
|
76630
76797
|
return new Xy7(transformed.x, transformed.y);
|
|
76631
76798
|
});
|
|
76632
76799
|
const grPoly = new PadPrimitiveGrPoly;
|
|
@@ -76738,8 +76905,8 @@ function createThruHolePadFromCircuitJson({
|
|
|
76738
76905
|
}
|
|
76739
76906
|
const relativeX = platedHole.x - componentCenter.x;
|
|
76740
76907
|
const relativeY = -(platedHole.y - componentCenter.y);
|
|
76741
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
76742
|
-
const rotatedPos =
|
|
76908
|
+
const rotationMatrix = componentRotation !== 0 ? rotate9(componentRotation * Math.PI / 180) : identity5();
|
|
76909
|
+
const rotatedPos = applyToPoint20(rotationMatrix, {
|
|
76743
76910
|
x: relativeX,
|
|
76744
76911
|
y: relativeY
|
|
76745
76912
|
});
|
|
@@ -76755,7 +76922,7 @@ function createThruHolePadFromCircuitJson({
|
|
|
76755
76922
|
y: platedHole.hole_offset_y ?? 0
|
|
76756
76923
|
};
|
|
76757
76924
|
if (rawOffset.x !== 0 || rawOffset.y !== 0) {
|
|
76758
|
-
const rotatedOffset =
|
|
76925
|
+
const rotatedOffset = applyToPoint20(rotationMatrix, {
|
|
76759
76926
|
x: -rawOffset.x,
|
|
76760
76927
|
y: rawOffset.y
|
|
76761
76928
|
});
|
|
@@ -76870,8 +77037,8 @@ function createNpthPadFromCircuitJson({
|
|
|
76870
77037
|
}
|
|
76871
77038
|
const relativeX = pcbHole.x - componentCenter.x;
|
|
76872
77039
|
const relativeY = -(pcbHole.y - componentCenter.y);
|
|
76873
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
76874
|
-
const rotatedPos =
|
|
77040
|
+
const rotationMatrix = componentRotation !== 0 ? rotate10(componentRotation * Math.PI / 180) : identity6();
|
|
77041
|
+
const rotatedPos = applyToPoint21(rotationMatrix, {
|
|
76875
77042
|
x: relativeX,
|
|
76876
77043
|
y: relativeY
|
|
76877
77044
|
});
|
|
@@ -76945,7 +77112,7 @@ function convertFabricationNotePaths(fabricationNotePaths, {
|
|
|
76945
77112
|
componentRotation = 0
|
|
76946
77113
|
}) {
|
|
76947
77114
|
const fpLines = [];
|
|
76948
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
77115
|
+
const rotationMatrix = componentRotation !== 0 ? rotate11(componentRotation * Math.PI / 180) : identity7();
|
|
76949
77116
|
for (const fabricationNotePath of fabricationNotePaths) {
|
|
76950
77117
|
if (fabricationNotePath.route.length < 2)
|
|
76951
77118
|
continue;
|
|
@@ -76955,15 +77122,15 @@ function convertFabricationNotePaths(fabricationNotePaths, {
|
|
|
76955
77122
|
const endPoint = fabricationNotePath.route[index + 1];
|
|
76956
77123
|
if (!startPoint || !endPoint)
|
|
76957
77124
|
continue;
|
|
76958
|
-
const startRelative =
|
|
77125
|
+
const startRelative = applyToPoint22(rotationMatrix, {
|
|
76959
77126
|
x: startPoint.x - componentCenter.x,
|
|
76960
77127
|
y: -(startPoint.y - componentCenter.y)
|
|
76961
77128
|
});
|
|
76962
|
-
const endRelative =
|
|
77129
|
+
const endRelative = applyToPoint22(rotationMatrix, {
|
|
76963
77130
|
x: endPoint.x - componentCenter.x,
|
|
76964
77131
|
y: -(endPoint.y - componentCenter.y)
|
|
76965
77132
|
});
|
|
76966
|
-
const stroke = new
|
|
77133
|
+
const stroke = new Stroke13;
|
|
76967
77134
|
stroke.width = fabricationNotePath.stroke_width || 0.1;
|
|
76968
77135
|
stroke.type = "default";
|
|
76969
77136
|
fpLines.push(new FpLine2({
|
|
@@ -76980,6 +77147,7 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
76980
77147
|
componentsProcessed = 0;
|
|
76981
77148
|
pcbComponents = [];
|
|
76982
77149
|
includeBuiltin3dModels;
|
|
77150
|
+
sourcePortNetKeys = /* @__PURE__ */ Object.create(null);
|
|
76983
77151
|
getNetInfoForPcbPort(pcbPortId) {
|
|
76984
77152
|
if (!pcbPortId)
|
|
76985
77153
|
return;
|
|
@@ -76992,10 +77160,23 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
76992
77160
|
const sourcePort = this.ctx.db.source_port?.get(sourcePortId);
|
|
76993
77161
|
if (!sourcePort)
|
|
76994
77162
|
return;
|
|
76995
|
-
const
|
|
76996
|
-
|
|
76997
|
-
|
|
76998
|
-
|
|
77163
|
+
const keys = [
|
|
77164
|
+
...this.sourcePortNetKeys[sourcePortId] ?? [],
|
|
77165
|
+
sourcePort.subcircuit_connectivity_map_key
|
|
77166
|
+
];
|
|
77167
|
+
const nets = [];
|
|
77168
|
+
for (const key of keys) {
|
|
77169
|
+
const net = key ? this.ctx.pcbNetMap?.get(key) : undefined;
|
|
77170
|
+
if (net && !nets.some((existing) => existing.id === net.id)) {
|
|
77171
|
+
nets.push(net);
|
|
77172
|
+
}
|
|
77173
|
+
}
|
|
77174
|
+
if (nets.length > 1) {
|
|
77175
|
+
const component = sourcePort.source_component_id ? this.ctx.db.source_component.get(sourcePort.source_component_id) : undefined;
|
|
77176
|
+
const reference = component?.name || sourcePort.source_component_id || pcbPort.pcb_component_id;
|
|
77177
|
+
throw new Error(`Cannot export ${reference} pad ${sourcePort.pin_number ?? sourcePort.name}: multiple KiCad nets (${nets.map((net) => net.name).join(", ")})`);
|
|
77178
|
+
}
|
|
77179
|
+
return nets[0];
|
|
76999
77180
|
}
|
|
77000
77181
|
getCadComponentForPcbComponent(pcbComponentId) {
|
|
77001
77182
|
const cadComponents = this.ctx.db.cad_component?.list() || [];
|
|
@@ -77005,6 +77186,19 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
77005
77186
|
super(input, ctx);
|
|
77006
77187
|
this.pcbComponents = this.ctx.db.pcb_component.list();
|
|
77007
77188
|
this.includeBuiltin3dModels = options?.includeBuiltin3dModels ?? false;
|
|
77189
|
+
for (const trace of ctx.db.source_trace.list()) {
|
|
77190
|
+
const keys = [
|
|
77191
|
+
trace.subcircuit_connectivity_map_key,
|
|
77192
|
+
...(trace.connected_source_net_ids ?? []).map((id) => {
|
|
77193
|
+
const net = ctx.db.source_net.get(id);
|
|
77194
|
+
return net?.subcircuit_connectivity_map_key || net?.source_net_id;
|
|
77195
|
+
})
|
|
77196
|
+
].filter((key) => Boolean(key));
|
|
77197
|
+
for (const portId of trace.connected_source_port_ids ?? []) {
|
|
77198
|
+
this.sourcePortNetKeys[portId] ??= [];
|
|
77199
|
+
this.sourcePortNetKeys[portId].push(...keys);
|
|
77200
|
+
}
|
|
77201
|
+
}
|
|
77008
77202
|
}
|
|
77009
77203
|
_step() {
|
|
77010
77204
|
const { kicadPcb, c2kMatPcb } = this.ctx;
|
|
@@ -77022,7 +77216,7 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
77022
77216
|
const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
|
|
77023
77217
|
const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
|
|
77024
77218
|
const footprintName = sourceComponent ? getKicadCompatibleComponentName(sourceComponent, cadComponent) : "Unknown";
|
|
77025
|
-
const transformedPos =
|
|
77219
|
+
const transformedPos = applyToPoint23(c2kMatPcb, {
|
|
77026
77220
|
x: component.center.x,
|
|
77027
77221
|
y: component.center.y
|
|
77028
77222
|
});
|
|
@@ -77113,6 +77307,12 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
77113
77307
|
componentCenter: component.center,
|
|
77114
77308
|
componentRotation: component.rotation || 0
|
|
77115
77309
|
});
|
|
77310
|
+
const pcbSilkscreenRects = this.ctx.db.pcb_silkscreen_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
77311
|
+
fpPolys.push(...convertSilkscreenRects({
|
|
77312
|
+
silkscreenRects: pcbSilkscreenRects,
|
|
77313
|
+
componentCenter: component.center,
|
|
77314
|
+
componentRotation: component.rotation || 0
|
|
77315
|
+
}));
|
|
77116
77316
|
if (fpPolys.length > 0) {
|
|
77117
77317
|
footprint.fpPolys = fpPolys;
|
|
77118
77318
|
}
|
|
@@ -77169,6 +77369,10 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
77169
77369
|
componentProperty: kicadComponentProperty
|
|
77170
77370
|
});
|
|
77171
77371
|
}
|
|
77372
|
+
if (component.do_not_place) {
|
|
77373
|
+
footprint.attr ??= new FootprintAttr3;
|
|
77374
|
+
footprint.attr.dnp = true;
|
|
77375
|
+
}
|
|
77172
77376
|
const footprints = kicadPcb.footprints;
|
|
77173
77377
|
footprints.push(footprint);
|
|
77174
77378
|
kicadPcb.footprints = footprints;
|
|
@@ -77242,8 +77446,8 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
77242
77446
|
if (!startPosition || !endPosition) {
|
|
77243
77447
|
throw new Error(`Unable to convert pcb_trace route segment ${trace.pcb_trace_id ?? this.tracesProcessed}:${i} to KiCad segment`);
|
|
77244
77448
|
}
|
|
77245
|
-
const transformedStart =
|
|
77246
|
-
const transformedEnd =
|
|
77449
|
+
const transformedStart = applyToPoint24(c2kMatPcb, startPosition);
|
|
77450
|
+
const transformedEnd = applyToPoint24(c2kMatPcb, endPosition);
|
|
77247
77451
|
if (transformedStart.x === transformedEnd.x && transformedStart.y === transformedEnd.y) {
|
|
77248
77452
|
continue;
|
|
77249
77453
|
}
|
|
@@ -77257,8 +77461,8 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
77257
77461
|
if (!connectivityKey && sourceTrace.connected_source_net_ids?.length) {
|
|
77258
77462
|
for (const sourceNetId of sourceTrace.connected_source_net_ids) {
|
|
77259
77463
|
const sourceNet = this.ctx.db.source_net?.get(sourceNetId);
|
|
77260
|
-
if (sourceNet
|
|
77261
|
-
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
77464
|
+
if (sourceNet) {
|
|
77465
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
77262
77466
|
break;
|
|
77263
77467
|
}
|
|
77264
77468
|
}
|
|
@@ -77267,8 +77471,8 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
77267
77471
|
}
|
|
77268
77472
|
if (!connectivityKey && typeof trace.connection_name === "string") {
|
|
77269
77473
|
const sourceNet = this.ctx.db.source_net?.get(trace.connection_name);
|
|
77270
|
-
if (sourceNet
|
|
77271
|
-
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
77474
|
+
if (sourceNet) {
|
|
77475
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
77272
77476
|
}
|
|
77273
77477
|
}
|
|
77274
77478
|
if (connectivityKey) {
|
|
@@ -77367,13 +77571,19 @@ var AddViasStage = class extends ConverterStage {
|
|
|
77367
77571
|
this.finished = true;
|
|
77368
77572
|
return;
|
|
77369
77573
|
}
|
|
77370
|
-
const transformedPos =
|
|
77574
|
+
const transformedPos = applyToPoint25(c2kMatPcb, {
|
|
77371
77575
|
x: via.x,
|
|
77372
77576
|
y: via.y
|
|
77373
77577
|
});
|
|
77374
77578
|
let netInfo;
|
|
77375
77579
|
if (pcbNetMap) {
|
|
77376
77580
|
let connectivityKey = via.subcircuit_connectivity_map_key;
|
|
77581
|
+
if (!connectivityKey && via.source_net_id) {
|
|
77582
|
+
const sourceNet = this.ctx.db.source_net?.get(via.source_net_id);
|
|
77583
|
+
if (sourceNet) {
|
|
77584
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
77585
|
+
}
|
|
77586
|
+
}
|
|
77377
77587
|
if (!connectivityKey && via.pcb_trace_id) {
|
|
77378
77588
|
const pcbTrace = this.ctx.db.pcb_trace?.get(via.pcb_trace_id);
|
|
77379
77589
|
if (pcbTrace) {
|
|
@@ -77389,8 +77599,8 @@ var AddViasStage = class extends ConverterStage {
|
|
|
77389
77599
|
if (!connectivityKey && sourceTrace.connected_source_net_ids?.length) {
|
|
77390
77600
|
for (const sourceNetId of sourceTrace.connected_source_net_ids) {
|
|
77391
77601
|
const sourceNet = this.ctx.db.source_net?.get(sourceNetId);
|
|
77392
|
-
if (sourceNet
|
|
77393
|
-
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
77602
|
+
if (sourceNet) {
|
|
77603
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
77394
77604
|
break;
|
|
77395
77605
|
}
|
|
77396
77606
|
}
|
|
@@ -77398,8 +77608,8 @@ var AddViasStage = class extends ConverterStage {
|
|
|
77398
77608
|
}
|
|
77399
77609
|
if (!connectivityKey) {
|
|
77400
77610
|
const sourceNet = this.ctx.db.source_net?.get(pcbTrace.source_trace_id);
|
|
77401
|
-
if (sourceNet
|
|
77402
|
-
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
77611
|
+
if (sourceNet) {
|
|
77612
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
77403
77613
|
}
|
|
77404
77614
|
}
|
|
77405
77615
|
}
|
|
@@ -77407,8 +77617,8 @@ var AddViasStage = class extends ConverterStage {
|
|
|
77407
77617
|
}
|
|
77408
77618
|
if (!connectivityKey && via.connection_name) {
|
|
77409
77619
|
const sourceNet = this.ctx.db.source_net?.get(via.connection_name);
|
|
77410
|
-
if (sourceNet
|
|
77411
|
-
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
77620
|
+
if (sourceNet) {
|
|
77621
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
77412
77622
|
}
|
|
77413
77623
|
}
|
|
77414
77624
|
if (connectivityKey) {
|
|
@@ -77463,7 +77673,7 @@ var AddStandalonePcbElements = class extends ConverterStage {
|
|
|
77463
77673
|
const pcbPad = elm;
|
|
77464
77674
|
const padCenter = this.getPcbSmtPadCenter(pcbPad);
|
|
77465
77675
|
const footprintSeed = `standalone_smtpad:${pcbPad.pcb_smtpad_id}:${padCenter.x},${padCenter.y}`;
|
|
77466
|
-
const kicadPos =
|
|
77676
|
+
const kicadPos = applyToPoint26(c2kMatPcb, padCenter);
|
|
77467
77677
|
const footprint = new Footprint4({
|
|
77468
77678
|
libraryLink: this.getSmtPadLibraryLink(pcbPad),
|
|
77469
77679
|
layer: "F.Cu",
|
|
@@ -77485,7 +77695,7 @@ var AddStandalonePcbElements = class extends ConverterStage {
|
|
|
77485
77695
|
} else if (elm.type === "pcb_hole") {
|
|
77486
77696
|
const hole = elm;
|
|
77487
77697
|
const footprintSeed = `standalone_hole:${hole.pcb_hole_id}:${hole.x},${hole.y}`;
|
|
77488
|
-
const kicadPos =
|
|
77698
|
+
const kicadPos = applyToPoint26(c2kMatPcb, { x: hole.x, y: hole.y });
|
|
77489
77699
|
const libraryLink = this.getHoleLibraryLink(hole);
|
|
77490
77700
|
const footprint = new Footprint4({
|
|
77491
77701
|
libraryLink,
|
|
@@ -77508,7 +77718,7 @@ var AddStandalonePcbElements = class extends ConverterStage {
|
|
|
77508
77718
|
} else if (elm.type === "pcb_plated_hole") {
|
|
77509
77719
|
const hole = elm;
|
|
77510
77720
|
const footprintSeed = `standalone_plated_hole:${hole.pcb_plated_hole_id}:${hole.x},${hole.y}`;
|
|
77511
|
-
const kicadPos =
|
|
77721
|
+
const kicadPos = applyToPoint26(c2kMatPcb, { x: hole.x, y: hole.y });
|
|
77512
77722
|
const libraryLink = this.getPlatedHoleLibraryLink(hole);
|
|
77513
77723
|
const footprint = new Footprint4({
|
|
77514
77724
|
libraryLink,
|
|
@@ -77605,7 +77815,7 @@ function createFabricationNoteTextFromCircuitJson({
|
|
|
77605
77815
|
if (!textElement.text || !textElement.anchor_position) {
|
|
77606
77816
|
return null;
|
|
77607
77817
|
}
|
|
77608
|
-
const transformedPos =
|
|
77818
|
+
const transformedPos = applyToPoint27(c2kMatPcb, {
|
|
77609
77819
|
x: textElement.anchor_position.x,
|
|
77610
77820
|
y: textElement.anchor_position.y
|
|
77611
77821
|
});
|
|
@@ -77663,7 +77873,7 @@ function createGrTextFromCircuitJson({
|
|
|
77663
77873
|
if (!textElement.text || !textElement.anchor_position) {
|
|
77664
77874
|
return null;
|
|
77665
77875
|
}
|
|
77666
|
-
const transformedPos =
|
|
77876
|
+
const transformedPos = applyToPoint28(c2kMatPcb, {
|
|
77667
77877
|
x: textElement.anchor_position.x,
|
|
77668
77878
|
y: textElement.anchor_position.y
|
|
77669
77879
|
});
|
|
@@ -77672,12 +77882,14 @@ function createGrTextFromCircuitJson({
|
|
|
77672
77882
|
bottom: "B.SilkS"
|
|
77673
77883
|
};
|
|
77674
77884
|
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
77885
|
+
const kicadLayerNames = textElement.is_knockout ? [kicadLayer, "knockout"] : kicadLayer;
|
|
77675
77886
|
const font = new TextEffectsFont13;
|
|
77887
|
+
const fontSize = textElement.font_size || 1;
|
|
77676
77888
|
font.size = {
|
|
77677
|
-
width:
|
|
77678
|
-
height:
|
|
77889
|
+
width: fontSize,
|
|
77890
|
+
height: fontSize
|
|
77679
77891
|
};
|
|
77680
|
-
font.thickness = 0.15;
|
|
77892
|
+
font.thickness = fontSize > 1 ? Math.min(0.3, fontSize * 0.2) : 0.15;
|
|
77681
77893
|
const textEffects = new TextEffects13({ font });
|
|
77682
77894
|
const justify = createPcbTextJustify({
|
|
77683
77895
|
anchorAlignment: textElement.anchor_alignment,
|
|
@@ -77691,7 +77903,7 @@ function createGrTextFromCircuitJson({
|
|
|
77691
77903
|
const position = new At4([transformedPos.x, transformedPos.y, rotation]);
|
|
77692
77904
|
const grText = new GrText2({
|
|
77693
77905
|
text: textElement.text,
|
|
77694
|
-
layer:
|
|
77906
|
+
layer: kicadLayerNames,
|
|
77695
77907
|
effects: textEffects,
|
|
77696
77908
|
uuid: generateDeterministicUuid(textElement.pcb_silkscreen_text_id ?? textElement.text)
|
|
77697
77909
|
});
|
|
@@ -77712,7 +77924,7 @@ var normalizeOutlineCorners = (corners) => {
|
|
|
77712
77924
|
}
|
|
77713
77925
|
return dedupedCorners;
|
|
77714
77926
|
};
|
|
77715
|
-
var
|
|
77927
|
+
var DEFAULT_EDGE_CUTS_WIDTH = 0.1;
|
|
77716
77928
|
var appendGraphicLine = (kicadPcb, grLine) => {
|
|
77717
77929
|
const graphicLines = kicadPcb.graphicLines;
|
|
77718
77930
|
graphicLines.push(grLine);
|
|
@@ -77721,7 +77933,7 @@ var appendGraphicLine = (kicadPcb, grLine) => {
|
|
|
77721
77933
|
var rotatePointAroundOrigin = (point, rotationDegrees = 0) => {
|
|
77722
77934
|
if (!rotationDegrees)
|
|
77723
77935
|
return point;
|
|
77724
|
-
return
|
|
77936
|
+
return applyToPoint29(rotate12(rotationDegrees * Math.PI / 180), point);
|
|
77725
77937
|
};
|
|
77726
77938
|
var getRectCutoutCorners = (cutout) => {
|
|
77727
77939
|
const halfWidth = cutout.width / 2;
|
|
@@ -77743,6 +77955,7 @@ var getRectCutoutCorners = (cutout) => {
|
|
|
77743
77955
|
var AddGraphicsStage = class extends ConverterStage {
|
|
77744
77956
|
_step() {
|
|
77745
77957
|
const { kicadPcb, c2kMatPcb } = this.ctx;
|
|
77958
|
+
const edgeCutsWidth = this.ctx.edgeCutsWidth ?? DEFAULT_EDGE_CUTS_WIDTH;
|
|
77746
77959
|
if (!kicadPcb) {
|
|
77747
77960
|
throw new Error("KicadPcb instance not initialized in context");
|
|
77748
77961
|
}
|
|
@@ -77758,11 +77971,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
77758
77971
|
const endPoint = path.route[i + 1];
|
|
77759
77972
|
if (!startPoint || !endPoint)
|
|
77760
77973
|
continue;
|
|
77761
|
-
const transformedStart =
|
|
77974
|
+
const transformedStart = applyToPoint29(c2kMatPcb, {
|
|
77762
77975
|
x: startPoint.x,
|
|
77763
77976
|
y: startPoint.y
|
|
77764
77977
|
});
|
|
77765
|
-
const transformedEnd =
|
|
77978
|
+
const transformedEnd = applyToPoint29(c2kMatPcb, {
|
|
77766
77979
|
x: endPoint.x,
|
|
77767
77980
|
y: endPoint.y
|
|
77768
77981
|
});
|
|
@@ -77842,7 +78055,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
77842
78055
|
}
|
|
77843
78056
|
for (const poly of boardGeom) {
|
|
77844
78057
|
for (const ring of poly) {
|
|
77845
|
-
const transformedRing = ring.map((point) =>
|
|
78058
|
+
const transformedRing = ring.map((point) => applyToPoint29(c2kMatPcb, { x: point[0], y: point[1] }));
|
|
77846
78059
|
for (let i = 0;i < transformedRing.length; i++) {
|
|
77847
78060
|
const start = transformedRing[i];
|
|
77848
78061
|
const end = transformedRing[(i + 1) % transformedRing.length];
|
|
@@ -77854,7 +78067,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
77854
78067
|
start: { x: start.x, y: start.y },
|
|
77855
78068
|
end: { x: end.x, y: end.y },
|
|
77856
78069
|
layer: "Edge.Cuts",
|
|
77857
|
-
width:
|
|
78070
|
+
width: edgeCutsWidth
|
|
77858
78071
|
});
|
|
77859
78072
|
appendGraphicLine(kicadPcb, edgeLine);
|
|
77860
78073
|
}
|
|
@@ -77871,13 +78084,13 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
77871
78084
|
const endPoint = cutout.route[i + 1];
|
|
77872
78085
|
if (!startPoint || !endPoint)
|
|
77873
78086
|
continue;
|
|
77874
|
-
const transformedStart =
|
|
77875
|
-
const transformedEnd =
|
|
78087
|
+
const transformedStart = applyToPoint29(c2kMatPcb, startPoint);
|
|
78088
|
+
const transformedEnd = applyToPoint29(c2kMatPcb, endPoint);
|
|
77876
78089
|
appendGraphicLine(kicadPcb, new GrLine({
|
|
77877
78090
|
start: transformedStart,
|
|
77878
78091
|
end: transformedEnd,
|
|
77879
78092
|
layer: "Edge.Cuts",
|
|
77880
|
-
width:
|
|
78093
|
+
width: edgeCutsWidth
|
|
77881
78094
|
}));
|
|
77882
78095
|
}
|
|
77883
78096
|
}
|
|
@@ -77907,8 +78120,9 @@ var CircuitJsonToKicadPcbConverter = class {
|
|
|
77907
78120
|
generator: "circuit-json-to-kicad",
|
|
77908
78121
|
generatorVersion: "0.0.1"
|
|
77909
78122
|
}),
|
|
77910
|
-
c2kMatPcb:
|
|
78123
|
+
c2kMatPcb: compose7(translate7(KICAD_PCB_CENTER_X, KICAD_PCB_CENTER_Y), scale5(CIRCUIT_JSON_TO_MM_SCALE, -CIRCUIT_JSON_TO_MM_SCALE)),
|
|
77911
78124
|
projectName: options?.projectName,
|
|
78125
|
+
edgeCutsWidth: options?.edgeCutsWidth,
|
|
77912
78126
|
pcbModel3dSourcePaths: []
|
|
77913
78127
|
};
|
|
77914
78128
|
this.pipeline = [
|