altium-to-circuit-json 0.0.43 → 0.0.44
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 +56 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -469,6 +469,7 @@ function normalizeLayer(layer) {
|
|
|
469
469
|
// lib/convert-altium-pcb-doc-to-circuit-json.ts
|
|
470
470
|
var MILS_TO_MILLIMETERS2 = 0.0254;
|
|
471
471
|
var ALTIUM_SLOT_HOLE_TYPE = 2;
|
|
472
|
+
var FABRICATION_NOTE_COLOR = "#ec4899";
|
|
472
473
|
var BOARD_ID = "pcb_board_altium";
|
|
473
474
|
var BOARD_GRAPHICS_COMPONENT_ID = "pcb_component_altium_board_graphics";
|
|
474
475
|
var ALTIUM_TEXT_ANCHORS = [
|
|
@@ -588,6 +589,15 @@ function convertAltiumPcbDocToCircuitJson(document, options = {}) {
|
|
|
588
589
|
}
|
|
589
590
|
if (record instanceof AltiumTextRecord) {
|
|
590
591
|
if (isCourtyardLayer(record.layer)) continue;
|
|
592
|
+
if (isMechanicalLayer(record.layer)) {
|
|
593
|
+
const text = convertMechanicalText({
|
|
594
|
+
document,
|
|
595
|
+
record,
|
|
596
|
+
recordIndex: index
|
|
597
|
+
});
|
|
598
|
+
if (text) elements.push(text);
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
591
601
|
if (isOverlayLayer(record.layer)) {
|
|
592
602
|
if (options.includeSilkscreen === false) continue;
|
|
593
603
|
const text = convertSilkscreenText(record, index);
|
|
@@ -642,7 +652,7 @@ function convertFabricationNotePath(record, index) {
|
|
|
642
652
|
layer: mapCourtyardLayer(getLayer(record)),
|
|
643
653
|
route: route.map(toMillimeterPoint),
|
|
644
654
|
stroke_width: milsToMillimeters2(record.widthMils ?? 4),
|
|
645
|
-
color:
|
|
655
|
+
color: FABRICATION_NOTE_COLOR
|
|
646
656
|
};
|
|
647
657
|
}
|
|
648
658
|
function convertCircularKeepout({
|
|
@@ -706,7 +716,7 @@ function convertDimension(record, index) {
|
|
|
706
716
|
font: "tscircuit2024",
|
|
707
717
|
font_size: milsToMillimeters2(record.textHeightMils ?? 50),
|
|
708
718
|
arrow_size: milsToMillimeters2(getMeasurement(record, "ARROWSIZE") ?? 40),
|
|
709
|
-
color:
|
|
719
|
+
color: FABRICATION_NOTE_COLOR
|
|
710
720
|
};
|
|
711
721
|
}
|
|
712
722
|
function getDimensionText(record, measuredDistanceMils) {
|
|
@@ -1294,6 +1304,43 @@ function convertSilkscreenText(record, index) {
|
|
|
1294
1304
|
is_mirrored: record.mirrored
|
|
1295
1305
|
};
|
|
1296
1306
|
}
|
|
1307
|
+
function convertMechanicalText({
|
|
1308
|
+
document,
|
|
1309
|
+
record,
|
|
1310
|
+
recordIndex
|
|
1311
|
+
}) {
|
|
1312
|
+
const componentIndex = record.componentIndex;
|
|
1313
|
+
const component = document.getComponentForRecord(record);
|
|
1314
|
+
if (!record.position || componentIndex === void 0 || !component) {
|
|
1315
|
+
return void 0;
|
|
1316
|
+
}
|
|
1317
|
+
const sourceText = decodeAltiumWideString(record.getDecoded("WIDESTRING")) || record.text;
|
|
1318
|
+
if (!sourceText) return void 0;
|
|
1319
|
+
const normalizedText = sourceText.trim().toUpperCase();
|
|
1320
|
+
const isDesignator = normalizedText === ".DESIGNATOR";
|
|
1321
|
+
const isComment = normalizedText === ".COMMENT";
|
|
1322
|
+
if (isDesignator && component.getBoolean("NAMEON") === false) {
|
|
1323
|
+
return void 0;
|
|
1324
|
+
}
|
|
1325
|
+
if (isComment && component.getBoolean("COMMENTON") === false) {
|
|
1326
|
+
return void 0;
|
|
1327
|
+
}
|
|
1328
|
+
const text = isDesignator ? component.designator : isComment ? component.comment : sourceText;
|
|
1329
|
+
if (!text) return void 0;
|
|
1330
|
+
return {
|
|
1331
|
+
type: "pcb_fabrication_note_text",
|
|
1332
|
+
pcb_fabrication_note_text_id: `pcb_fabrication_note_text_altium_${recordIndex}`,
|
|
1333
|
+
pcb_component_id: componentId(componentIndex),
|
|
1334
|
+
text,
|
|
1335
|
+
font: "tscircuit2024",
|
|
1336
|
+
font_size: milsToMillimeters2(record.heightMils ?? 30),
|
|
1337
|
+
anchor_position: toMillimeterPoint(record.position),
|
|
1338
|
+
anchor_alignment: mapFabricationTextAnchor(record.justification),
|
|
1339
|
+
ccw_rotation: record.rotation,
|
|
1340
|
+
layer: component.side === "bottom" ? "bottom" : "top",
|
|
1341
|
+
color: FABRICATION_NOTE_COLOR
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1297
1344
|
function decodeAltiumWideString(raw) {
|
|
1298
1345
|
if (!raw) return "";
|
|
1299
1346
|
if (!/^\d+(?:,\d+)*$/u.test(raw)) return raw;
|
|
@@ -1319,6 +1366,13 @@ function mapTextAnchor(justification) {
|
|
|
1319
1366
|
if (normalized?.includes("LEFT")) return "bottom_left";
|
|
1320
1367
|
return "center";
|
|
1321
1368
|
}
|
|
1369
|
+
function mapFabricationTextAnchor(justification) {
|
|
1370
|
+
const anchor = mapTextAnchor(justification);
|
|
1371
|
+
return anchor === "top_left" || anchor === "top_right" || anchor === "bottom_left" || anchor === "bottom_right" ? anchor : "center";
|
|
1372
|
+
}
|
|
1373
|
+
function isMechanicalLayer(layer) {
|
|
1374
|
+
return normalizeLayer2(layer).startsWith("MECHANICAL");
|
|
1375
|
+
}
|
|
1322
1376
|
function isOverlayLayer(layer) {
|
|
1323
1377
|
const normalized = normalizeLayer2(layer);
|
|
1324
1378
|
return normalized === "TOPOVERLAY" || normalized === "BOTTOMOVERLAY";
|