circuit-json-to-lbrn 0.0.29 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +50 -66
  3. package/lib/ConvertContext.ts +2 -2
  4. package/lib/element-handlers/addPcbCutout/addCirclePcbCutout.ts +1 -3
  5. package/lib/element-handlers/addPcbCutout/addPathPcbCutout.ts +0 -1
  6. package/lib/element-handlers/addPcbCutout/addPolygonPcbCutout.ts +1 -17
  7. package/lib/element-handlers/addPcbCutout/addRectPcbCutout.ts +2 -5
  8. package/lib/element-handlers/addPcbHole/addCirclePcbHole.ts +1 -3
  9. package/lib/element-handlers/addPcbHole/addOvalPcbHole.ts +2 -3
  10. package/lib/element-handlers/addPcbHole/addPillPcbHole.ts +2 -3
  11. package/lib/element-handlers/addPcbHole/addRectPcbHole.ts +2 -3
  12. package/lib/element-handlers/addPcbHole/addRotatedPillPcbHole.ts +2 -3
  13. package/lib/element-handlers/addPcbVia/index.ts +3 -2
  14. package/lib/element-handlers/addPlatedHole/addCirclePlatedHole.ts +5 -2
  15. package/lib/element-handlers/addPlatedHole/addCircularHoleWithRectPad.ts +9 -3
  16. package/lib/element-handlers/addPlatedHole/addHoleWithPolygonPad.ts +1 -1
  17. package/lib/element-handlers/addPlatedHole/addOvalPlatedHole.ts +4 -1
  18. package/lib/element-handlers/addPlatedHole/addPillHoleWithRectPad.ts +9 -3
  19. package/lib/element-handlers/addPlatedHole/addPillPlatedHole.ts +9 -3
  20. package/lib/element-handlers/addPlatedHole/addRotatedPillHoleWithRectPad.ts +9 -3
  21. package/lib/element-handlers/addSmtPad/addCircleSmtPad.ts +5 -2
  22. package/lib/element-handlers/addSmtPad/addPillSmtPad.ts +9 -3
  23. package/lib/element-handlers/addSmtPad/addPolygonSmtPad.ts +1 -1
  24. package/lib/element-handlers/addSmtPad/addRectSmtPad.ts +9 -3
  25. package/lib/element-handlers/addSmtPad/addRotatedPillSmtPad.ts +9 -3
  26. package/lib/element-handlers/addSmtPad/addRotatedRectSmtPad.ts +9 -3
  27. package/lib/index.ts +4 -3
  28. package/package.json +1 -1
  29. package/site/index.html +1 -1
  30. package/site/main.tsx +4 -3
  31. package/tests/basics/__snapshots__/mixed-soldermask-margins.snap.svg +8 -0
  32. package/tests/basics/addPcbCutout/__snapshots__/pcb-cutout-circle.snap.svg +1 -1
  33. package/tests/basics/addPcbCutout/pcb-cutout-circle.test.ts +1 -1
  34. package/tests/basics/addPcbHole/__snapshots__/pcb-hole-soldermask-margin.snap.svg +8 -0
  35. package/tests/basics/addPcbHole/__snapshots__/pcb-hole-with-soldermask.snap.svg +1 -1
  36. package/tests/basics/addPcbHole/pcb-hole-soldermask-margin.test.ts +63 -0
  37. package/tests/basics/addPcbHole/pcb-hole-with-soldermask.test.ts +1 -1
  38. package/tests/basics/addPcbVia/pcb-via-with-soldermask.test.ts +1 -1
  39. package/tests/basics/mixed-soldermask-margins.test.ts +111 -0
  40. package/tests/basics/soldermask-margin/negative-soldermask-margin.test.ts +1 -1
  41. package/tests/basics/soldermask-margin/positive-soldermask-margin.test.ts +1 -1
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ declare const convertCircuitJsonToLbrn: (circuitJson: CircuitJson, options?: {
10
10
  margin?: number;
11
11
  includeCopper?: boolean;
12
12
  includeSoldermask?: boolean;
13
- soldermaskMargin?: number;
13
+ globalCopperSoldermaskMarginAdjustment?: number;
14
14
  includeLayers?: Array<"top" | "bottom">;
15
15
  traceMargin?: number;
16
16
  laserSpotSize?: number;
package/dist/index.js CHANGED
@@ -61,7 +61,7 @@ var addCirclePlatedHole = (platedHole, ctx) => {
61
61
  includeCopper,
62
62
  includeSoldermask,
63
63
  connMap,
64
- soldermaskMargin,
64
+ globalCopperSoldermaskMarginAdjustment,
65
65
  includeLayers
66
66
  } = ctx;
67
67
  const centerX = platedHole.x + origin.x;
@@ -107,7 +107,7 @@ var addCirclePlatedHole = (platedHole, ctx) => {
107
107
  }
108
108
  }
109
109
  if (platedHole.outer_diameter > 0 && includeSoldermask) {
110
- const smRadius = platedHole.outer_diameter / 2 + soldermaskMargin;
110
+ const smRadius = platedHole.outer_diameter / 2 + globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
111
111
  const outer = createCirclePath({
112
112
  centerX,
113
113
  centerY,
@@ -188,7 +188,7 @@ var addOvalPlatedHole = (platedHole, ctx) => {
188
188
  origin,
189
189
  includeCopper,
190
190
  includeSoldermask,
191
- soldermaskMargin,
191
+ globalCopperSoldermaskMarginAdjustment,
192
192
  includeLayers
193
193
  } = ctx;
194
194
  if (platedHole.outer_width <= 0 || platedHole.outer_height <= 0) {
@@ -227,6 +227,7 @@ var addOvalPlatedHole = (platedHole, ctx) => {
227
227
  }
228
228
  }
229
229
  if (platedHole.outer_width > 0 && platedHole.outer_height > 0 && includeSoldermask) {
230
+ const soldermaskMargin = globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
230
231
  const smWidth = platedHole.outer_width + 2 * soldermaskMargin;
231
232
  const smHeight = platedHole.outer_height + 2 * soldermaskMargin;
232
233
  const outer = createOvalPath({
@@ -367,7 +368,7 @@ var addCircularHoleWithRectPad = (platedHole, ctx) => {
367
368
  origin,
368
369
  includeCopper,
369
370
  includeSoldermask,
370
- soldermaskMargin,
371
+ globalCopperSoldermaskMarginAdjustment,
371
372
  includeLayers
372
373
  } = ctx;
373
374
  const centerX = platedHole.x + origin.x;
@@ -406,8 +407,8 @@ var addCircularHoleWithRectPad = (platedHole, ctx) => {
406
407
  }
407
408
  }
408
409
  if (includeSoldermask) {
409
- const smPadWidth = padWidth + 2 * soldermaskMargin;
410
- const smPadHeight = padHeight + 2 * soldermaskMargin;
410
+ const smPadWidth = padWidth + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
411
+ const smPadHeight = padHeight + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
411
412
  const smPadPath = createRoundedRectPath({
412
413
  centerX,
413
414
  centerY,
@@ -552,7 +553,7 @@ var addPillHoleWithRectPad = (platedHole, ctx) => {
552
553
  origin,
553
554
  includeCopper,
554
555
  includeSoldermask,
555
- soldermaskMargin,
556
+ globalCopperSoldermaskMarginAdjustment,
556
557
  includeLayers
557
558
  } = ctx;
558
559
  const centerX = platedHole.x + origin.x;
@@ -591,8 +592,8 @@ var addPillHoleWithRectPad = (platedHole, ctx) => {
591
592
  }
592
593
  }
593
594
  if (includeSoldermask) {
594
- const smPadWidth = padWidth + 2 * soldermaskMargin;
595
- const smPadHeight = padHeight + 2 * soldermaskMargin;
595
+ const smPadWidth = padWidth + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
596
+ const smPadHeight = padHeight + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
596
597
  const smPadPath = createRoundedRectPath({
597
598
  centerX,
598
599
  centerY,
@@ -644,7 +645,7 @@ var addRotatedPillHoleWithRectPad = (platedHole, ctx) => {
644
645
  origin,
645
646
  includeCopper,
646
647
  includeSoldermask,
647
- soldermaskMargin,
648
+ globalCopperSoldermaskMarginAdjustment,
648
649
  includeLayers
649
650
  } = ctx;
650
651
  const centerX = platedHole.x + origin.x;
@@ -686,8 +687,8 @@ var addRotatedPillHoleWithRectPad = (platedHole, ctx) => {
686
687
  }
687
688
  }
688
689
  if (includeSoldermask) {
689
- const smPadWidth = padWidth + 2 * soldermaskMargin;
690
- const smPadHeight = padHeight + 2 * soldermaskMargin;
690
+ const smPadWidth = padWidth + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
691
+ const smPadHeight = padHeight + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
691
692
  const smPadPath = createRoundedRectPath({
692
693
  centerX,
693
694
  centerY,
@@ -766,7 +767,7 @@ var addHoleWithPolygonPad = (platedHole, ctx) => {
766
767
  origin,
767
768
  includeCopper,
768
769
  includeSoldermask,
769
- soldermaskMargin,
770
+ globalCopperSoldermaskMarginAdjustment,
770
771
  includeLayers
771
772
  } = ctx;
772
773
  if (platedHole.pad_outline.length >= 3 && includeCopper) {
@@ -860,7 +861,7 @@ var addPcbPlatedHolePill = (platedHole, ctx) => {
860
861
  origin,
861
862
  includeCopper,
862
863
  includeSoldermask,
863
- soldermaskMargin,
864
+ globalCopperSoldermaskMarginAdjustment,
864
865
  includeLayers
865
866
  } = ctx;
866
867
  const centerX = platedHole.x + origin.x;
@@ -896,8 +897,8 @@ var addPcbPlatedHolePill = (platedHole, ctx) => {
896
897
  }
897
898
  }
898
899
  if (platedHole.outer_width > 0 && platedHole.outer_height > 0 && includeSoldermask) {
899
- const smWidth = platedHole.outer_width + 2 * soldermaskMargin;
900
- const smHeight = platedHole.outer_height + 2 * soldermaskMargin;
900
+ const smWidth = platedHole.outer_width + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
901
+ const smHeight = platedHole.outer_height + 2 * globalCopperSoldermaskMarginAdjustment + (platedHole.soldermask_margin ?? 0);
901
902
  const outer = createPillPath({
902
903
  centerX,
903
904
  centerY,
@@ -971,7 +972,7 @@ var addRectSmtPad = (smtPad, ctx) => {
971
972
  origin,
972
973
  includeCopper,
973
974
  includeSoldermask,
974
- soldermaskMargin,
975
+ globalCopperSoldermaskMarginAdjustment,
975
976
  includeLayers
976
977
  } = ctx;
977
978
  const padLayer = smtPad.layer || "top";
@@ -1025,8 +1026,8 @@ var addRectSmtPad = (smtPad, ctx) => {
1025
1026
  }
1026
1027
  }
1027
1028
  if (includeSoldermask) {
1028
- const smHalfWidth = halfWidth + soldermaskMargin;
1029
- const smHalfHeight = halfHeight + soldermaskMargin;
1029
+ const smHalfWidth = halfWidth + globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1030
+ const smHalfHeight = halfHeight + globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1030
1031
  const verts = [
1031
1032
  { x: centerX - smHalfWidth, y: centerY - smHalfHeight },
1032
1033
  { x: centerX + smHalfWidth, y: centerY - smHalfHeight },
@@ -1068,7 +1069,7 @@ var addCircleSmtPad = (smtPad, ctx) => {
1068
1069
  includeCopper,
1069
1070
  includeSoldermask,
1070
1071
  connMap,
1071
- soldermaskMargin,
1072
+ globalCopperSoldermaskMarginAdjustment,
1072
1073
  includeLayers
1073
1074
  } = ctx;
1074
1075
  const padLayer = smtPad.layer || "top";
@@ -1107,7 +1108,7 @@ var addCircleSmtPad = (smtPad, ctx) => {
1107
1108
  }
1108
1109
  }
1109
1110
  if (includeSoldermask) {
1110
- const smRadius = outerRadius + soldermaskMargin;
1111
+ const smRadius = outerRadius + globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1111
1112
  const outer = createCirclePath({
1112
1113
  centerX,
1113
1114
  centerY,
@@ -1148,7 +1149,7 @@ var addPillSmtPad = (smtPad, ctx) => {
1148
1149
  includeCopper,
1149
1150
  includeSoldermask,
1150
1151
  connMap,
1151
- soldermaskMargin,
1152
+ globalCopperSoldermaskMarginAdjustment,
1152
1153
  includeLayers
1153
1154
  } = ctx;
1154
1155
  const padLayer = smtPad.layer || "top";
@@ -1186,8 +1187,8 @@ var addPillSmtPad = (smtPad, ctx) => {
1186
1187
  }
1187
1188
  }
1188
1189
  if (includeSoldermask) {
1189
- const smWidth = smtPad.width + 2 * soldermaskMargin;
1190
- const smHeight = smtPad.height + 2 * soldermaskMargin;
1190
+ const smWidth = smtPad.width + 2 * globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1191
+ const smHeight = smtPad.height + 2 * globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1191
1192
  const smOuter = createPillPath({
1192
1193
  centerX,
1193
1194
  centerY,
@@ -1220,7 +1221,7 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
1220
1221
  includeCopper,
1221
1222
  includeSoldermask,
1222
1223
  connMap,
1223
- soldermaskMargin,
1224
+ globalCopperSoldermaskMarginAdjustment,
1224
1225
  includeLayers
1225
1226
  } = ctx;
1226
1227
  const padLayer = smtPad.layer || "top";
@@ -1259,8 +1260,8 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
1259
1260
  }
1260
1261
  }
1261
1262
  if (includeSoldermask) {
1262
- const smWidth = smtPad.width + 2 * soldermaskMargin;
1263
- const smHeight = smtPad.height + 2 * soldermaskMargin;
1263
+ const smWidth = smtPad.width + 2 * globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1264
+ const smHeight = smtPad.height + 2 * globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1264
1265
  const smOuter = createPillPath({
1265
1266
  centerX,
1266
1267
  centerY,
@@ -1323,7 +1324,7 @@ var addPolygonSmtPad = (smtPad, ctx) => {
1323
1324
  includeCopper,
1324
1325
  includeSoldermask,
1325
1326
  connMap,
1326
- soldermaskMargin,
1327
+ globalCopperSoldermaskMarginAdjustment,
1327
1328
  includeLayers
1328
1329
  } = ctx;
1329
1330
  const padLayer = smtPad.layer || "top";
@@ -1384,7 +1385,7 @@ var addRotatedRectSmtPad = (smtPad, ctx) => {
1384
1385
  includeCopper,
1385
1386
  includeSoldermask,
1386
1387
  connMap,
1387
- soldermaskMargin,
1388
+ globalCopperSoldermaskMarginAdjustment,
1388
1389
  includeLayers
1389
1390
  } = ctx;
1390
1391
  const padLayer = smtPad.layer || "top";
@@ -1427,8 +1428,8 @@ var addRotatedRectSmtPad = (smtPad, ctx) => {
1427
1428
  }
1428
1429
  }
1429
1430
  if (includeSoldermask) {
1430
- const smWidth = smtPad.width + 2 * soldermaskMargin;
1431
- const smHeight = smtPad.height + 2 * soldermaskMargin;
1431
+ const smWidth = smtPad.width + 2 * globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1432
+ const smHeight = smtPad.height + 2 * globalCopperSoldermaskMarginAdjustment + (smtPad.soldermask_margin ?? 0);
1432
1433
  const smOuter = createRoundedRectPath({
1433
1434
  centerX,
1434
1435
  centerY,
@@ -1913,7 +1914,7 @@ var addPcbVia = (via, ctx) => {
1913
1914
  includeCopper,
1914
1915
  includeSoldermask,
1915
1916
  connMap,
1916
- soldermaskMargin,
1917
+ globalCopperSoldermaskMarginAdjustment,
1917
1918
  includeLayers
1918
1919
  } = ctx;
1919
1920
  const centerX = via.x + origin.x;
@@ -1960,7 +1961,7 @@ var addPcbVia = (via, ctx) => {
1960
1961
  }
1961
1962
  }
1962
1963
  if (via.outer_diameter > 0 && includeSoldermask) {
1963
- const smRadius = via.outer_diameter / 2 + soldermaskMargin;
1964
+ const smRadius = via.outer_diameter / 2 + globalCopperSoldermaskMarginAdjustment;
1964
1965
  const outer = createCirclePath({
1965
1966
  centerX,
1966
1967
  centerY,
@@ -2002,17 +2003,15 @@ var addCirclePcbHole = (hole, ctx) => {
2002
2003
  soldermaskCutSetting,
2003
2004
  origin,
2004
2005
  includeSoldermask,
2005
- soldermaskMargin,
2006
2006
  includeCopper
2007
2007
  } = ctx;
2008
2008
  const centerX = hole.x + origin.x;
2009
2009
  const centerY = hole.y + origin.y;
2010
2010
  if (hole.hole_diameter > 0 && includeSoldermask) {
2011
- const smRadius = hole.hole_diameter / 2 + soldermaskMargin;
2012
2011
  const soldermaskPath = createCirclePath({
2013
2012
  centerX,
2014
2013
  centerY,
2015
- radius: smRadius
2014
+ radius: hole.hole_diameter / 2 + (hole.soldermask_margin ?? 0)
2016
2015
  });
2017
2016
  project.children.push(
2018
2017
  new ShapePath16({
@@ -2050,7 +2049,6 @@ var addRectPcbHole = (hole, ctx) => {
2050
2049
  soldermaskCutSetting,
2051
2050
  origin,
2052
2051
  includeSoldermask,
2053
- soldermaskMargin,
2054
2052
  includeCopper
2055
2053
  } = ctx;
2056
2054
  const centerX = hole.x + origin.x;
@@ -2059,8 +2057,8 @@ var addRectPcbHole = (hole, ctx) => {
2059
2057
  const soldermaskPath = createRoundedRectPath({
2060
2058
  centerX,
2061
2059
  centerY,
2062
- width: hole.hole_width + soldermaskMargin * 2,
2063
- height: hole.hole_height + soldermaskMargin * 2,
2060
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
2061
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0),
2064
2062
  borderRadius: 0
2065
2063
  // no border radius for rect holes
2066
2064
  });
@@ -2102,7 +2100,6 @@ var addOvalPcbHole = (hole, ctx) => {
2102
2100
  soldermaskCutSetting,
2103
2101
  origin,
2104
2102
  includeSoldermask,
2105
- soldermaskMargin,
2106
2103
  includeCopper
2107
2104
  } = ctx;
2108
2105
  const centerX = hole.x + origin.x;
@@ -2111,8 +2108,8 @@ var addOvalPcbHole = (hole, ctx) => {
2111
2108
  const soldermaskPath = createOvalPath({
2112
2109
  centerX,
2113
2110
  centerY,
2114
- width: hole.hole_width + soldermaskMargin * 2,
2115
- height: hole.hole_height + soldermaskMargin * 2
2111
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
2112
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0)
2116
2113
  });
2117
2114
  project.children.push(
2118
2115
  new ShapePath18({
@@ -2150,7 +2147,6 @@ var addPillPcbHole = (hole, ctx) => {
2150
2147
  soldermaskCutSetting,
2151
2148
  origin,
2152
2149
  includeSoldermask,
2153
- soldermaskMargin,
2154
2150
  includeCopper
2155
2151
  } = ctx;
2156
2152
  const centerX = hole.x + origin.x;
@@ -2159,8 +2155,8 @@ var addPillPcbHole = (hole, ctx) => {
2159
2155
  const soldermaskPath = createPillPath({
2160
2156
  centerX,
2161
2157
  centerY,
2162
- width: hole.hole_width + soldermaskMargin * 2,
2163
- height: hole.hole_height + soldermaskMargin * 2
2158
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
2159
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0)
2164
2160
  });
2165
2161
  project.children.push(
2166
2162
  new ShapePath19({
@@ -2198,7 +2194,6 @@ var addRotatedPillPcbHole = (hole, ctx) => {
2198
2194
  soldermaskCutSetting,
2199
2195
  origin,
2200
2196
  includeSoldermask,
2201
- soldermaskMargin,
2202
2197
  includeCopper
2203
2198
  } = ctx;
2204
2199
  const centerX = hole.x + origin.x;
@@ -2208,8 +2203,8 @@ var addRotatedPillPcbHole = (hole, ctx) => {
2208
2203
  const soldermaskPath = createPillPath({
2209
2204
  centerX,
2210
2205
  centerY,
2211
- width: hole.hole_width + soldermaskMargin * 2,
2212
- height: hole.hole_height + soldermaskMargin * 2,
2206
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
2207
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0),
2213
2208
  rotation
2214
2209
  });
2215
2210
  project.children.push(
@@ -2269,7 +2264,6 @@ var addCirclePcbCutout = (cutout, ctx) => {
2269
2264
  origin,
2270
2265
  includeCopper,
2271
2266
  includeSoldermask,
2272
- soldermaskMargin,
2273
2267
  soldermaskCutSetting
2274
2268
  } = ctx;
2275
2269
  const centerX = cutout.center.x + origin.x;
@@ -2290,11 +2284,10 @@ var addCirclePcbCutout = (cutout, ctx) => {
2290
2284
  );
2291
2285
  }
2292
2286
  if (cutout.radius > 0 && includeSoldermask) {
2293
- const smRadius = cutout.radius + soldermaskMargin;
2294
2287
  const outer = createCirclePath({
2295
2288
  centerX,
2296
2289
  centerY,
2297
- radius: smRadius
2290
+ radius: cutout.radius
2298
2291
  });
2299
2292
  project.children.push(
2300
2293
  new ShapePath21({
@@ -2316,7 +2309,6 @@ var addRectPcbCutout = (cutout, ctx) => {
2316
2309
  origin,
2317
2310
  includeCopper,
2318
2311
  includeSoldermask,
2319
- soldermaskMargin,
2320
2312
  soldermaskCutSetting
2321
2313
  } = ctx;
2322
2314
  const centerX = cutout.center.x + origin.x;
@@ -2345,13 +2337,11 @@ var addRectPcbCutout = (cutout, ctx) => {
2345
2337
  }
2346
2338
  if (cutout.width > 0 && cutout.height > 0 && includeSoldermask) {
2347
2339
  const rotation = (cutout.rotation ?? 0) * (Math.PI / 180);
2348
- const smWidth = cutout.width + 2 * soldermaskMargin;
2349
- const smHeight = cutout.height + 2 * soldermaskMargin;
2350
2340
  const rectPath = createRoundedRectPath({
2351
2341
  centerX,
2352
2342
  centerY,
2353
- width: smWidth,
2354
- height: smHeight,
2343
+ width: cutout.width,
2344
+ height: cutout.height,
2355
2345
  borderRadius: 0,
2356
2346
  // no border radius for cutouts
2357
2347
  segments: 4,
@@ -2378,8 +2368,7 @@ var addPolygonPcbCutout = (cutout, ctx) => {
2378
2368
  origin,
2379
2369
  includeCopper,
2380
2370
  includeSoldermask,
2381
- soldermaskCutSetting,
2382
- soldermaskMargin
2371
+ soldermaskCutSetting
2383
2372
  } = ctx;
2384
2373
  if (cutout.points.length >= 3 && includeCopper) {
2385
2374
  const polygonPath = createPolygonPathFromOutline({
@@ -2397,12 +2386,8 @@ var addPolygonPcbCutout = (cutout, ctx) => {
2397
2386
  );
2398
2387
  }
2399
2388
  if (cutout.points.length >= 3 && includeSoldermask) {
2400
- const points = soldermaskMargin && soldermaskMargin > 0 ? cutout.points.map((p) => ({
2401
- x: (p.x ?? 0) + (p.x ?? 0) > 0 ? soldermaskMargin : -soldermaskMargin,
2402
- y: (p.y ?? 0) + (p.y ?? 0) > 0 ? soldermaskMargin : -soldermaskMargin
2403
- })) : cutout.points;
2404
2389
  const polygonPath = createPolygonPathFromOutline({
2405
- outline: points,
2390
+ outline: cutout.points,
2406
2391
  offsetX: origin.x,
2407
2392
  offsetY: origin.y
2408
2393
  });
@@ -2426,7 +2411,6 @@ var addPathPcbCutout = (cutout, ctx) => {
2426
2411
  origin,
2427
2412
  includeCopper,
2428
2413
  includeSoldermask,
2429
- soldermaskMargin,
2430
2414
  soldermaskCutSetting
2431
2415
  } = ctx;
2432
2416
  if (cutout.route.length >= 2 && includeCopper) {
@@ -2659,7 +2643,7 @@ var convertCircuitJsonToLbrn = (circuitJson, options = {}) => {
2659
2643
  const laserSpotSize = options.laserSpotSize ?? 5e-3;
2660
2644
  const includeCopper = options.includeCopper ?? true;
2661
2645
  const includeSoldermask = options.includeSoldermask ?? false;
2662
- const soldermaskMargin = options.soldermaskMargin ?? 0;
2646
+ const globalCopperSoldermaskMarginAdjustment = options.globalCopperSoldermaskMarginAdjustment ?? 0;
2663
2647
  const laserProfile = options.laserProfile;
2664
2648
  const defaultCopperSettings = {
2665
2649
  speed: 300,
@@ -2771,7 +2755,7 @@ var convertCircuitJsonToLbrn = (circuitJson, options = {}) => {
2771
2755
  origin,
2772
2756
  includeCopper,
2773
2757
  includeSoldermask,
2774
- soldermaskMargin,
2758
+ globalCopperSoldermaskMarginAdjustment,
2775
2759
  includeLayers,
2776
2760
  traceMargin,
2777
2761
  laserSpotSize,
@@ -33,8 +33,8 @@ export interface ConvertContext {
33
33
  includeSoldermask: boolean
34
34
  includeLayers: Array<"top" | "bottom">
35
35
 
36
- // Soldermask margin (can be negative)
37
- soldermaskMargin: number
36
+ // Global copper soldermask margin adjustment (can be negative)
37
+ globalCopperSoldermaskMarginAdjustment: number
38
38
 
39
39
  // Trace margin for clearance zones
40
40
  traceMargin: number
@@ -17,7 +17,6 @@ export const addCirclePcbCutout = (
17
17
  origin,
18
18
  includeCopper,
19
19
  includeSoldermask,
20
- soldermaskMargin,
21
20
  soldermaskCutSetting,
22
21
  } = ctx
23
22
  const centerX = cutout.center.x + origin.x
@@ -42,11 +41,10 @@ export const addCirclePcbCutout = (
42
41
 
43
42
  // Add soldermask opening if drawing soldermask
44
43
  if (cutout.radius > 0 && includeSoldermask) {
45
- const smRadius = cutout.radius + soldermaskMargin
46
44
  const outer = createCirclePath({
47
45
  centerX,
48
46
  centerY,
49
- radius: smRadius,
47
+ radius: cutout.radius,
50
48
  })
51
49
  project.children.push(
52
50
  new ShapePath({
@@ -16,7 +16,6 @@ export const addPathPcbCutout = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
- soldermaskMargin,
20
19
  soldermaskCutSetting,
21
20
  } = ctx
22
21
 
@@ -18,7 +18,6 @@ export const addPolygonPcbCutout = (
18
18
  includeCopper,
19
19
  includeSoldermask,
20
20
  soldermaskCutSetting,
21
- soldermaskMargin,
22
21
  } = ctx
23
22
 
24
23
  // Add the cutout - cut through the board
@@ -40,23 +39,8 @@ export const addPolygonPcbCutout = (
40
39
 
41
40
  // Add soldermask opening if drawing soldermask
42
41
  if (cutout.points.length >= 3 && includeSoldermask) {
43
- // Apply soldermask margin to the points if margin is specified
44
- const points =
45
- soldermaskMargin && soldermaskMargin > 0
46
- ? cutout.points.map((p) => ({
47
- x:
48
- (p.x ?? 0) + (p.x ?? 0) > 0
49
- ? soldermaskMargin
50
- : -soldermaskMargin,
51
- y:
52
- (p.y ?? 0) + (p.y ?? 0) > 0
53
- ? soldermaskMargin
54
- : -soldermaskMargin,
55
- }))
56
- : cutout.points
57
-
58
42
  const polygonPath = createPolygonPathFromOutline({
59
- outline: points,
43
+ outline: cutout.points,
60
44
  offsetX: origin.x,
61
45
  offsetY: origin.y,
62
46
  })
@@ -17,7 +17,6 @@ export const addRectPcbCutout = (
17
17
  origin,
18
18
  includeCopper,
19
19
  includeSoldermask,
20
- soldermaskMargin,
21
20
  soldermaskCutSetting,
22
21
  } = ctx
23
22
  const centerX = cutout.center.x + origin.x
@@ -48,13 +47,11 @@ export const addRectPcbCutout = (
48
47
  // Add soldermask opening if drawing soldermask
49
48
  if (cutout.width > 0 && cutout.height > 0 && includeSoldermask) {
50
49
  const rotation = (cutout.rotation ?? 0) * (Math.PI / 180) // Convert degrees to radians
51
- const smWidth = cutout.width + 2 * soldermaskMargin
52
- const smHeight = cutout.height + 2 * soldermaskMargin
53
50
  const rectPath = createRoundedRectPath({
54
51
  centerX,
55
52
  centerY,
56
- width: smWidth,
57
- height: smHeight,
53
+ width: cutout.width,
54
+ height: cutout.height,
58
55
  borderRadius: 0, // no border radius for cutouts
59
56
  segments: 4, // segments
60
57
  rotation,
@@ -16,7 +16,6 @@ export const addCirclePcbHole = (
16
16
  soldermaskCutSetting,
17
17
  origin,
18
18
  includeSoldermask,
19
- soldermaskMargin,
20
19
  includeCopper,
21
20
  } = ctx
22
21
  const centerX = hole.x + origin.x
@@ -24,11 +23,10 @@ export const addCirclePcbHole = (
24
23
 
25
24
  // Add soldermask opening if drawing soldermask
26
25
  if (hole.hole_diameter > 0 && includeSoldermask) {
27
- const smRadius = hole.hole_diameter / 2 + soldermaskMargin
28
26
  const soldermaskPath = createCirclePath({
29
27
  centerX,
30
28
  centerY,
31
- radius: smRadius,
29
+ radius: hole.hole_diameter / 2 + (hole.soldermask_margin ?? 0),
32
30
  })
33
31
  project.children.push(
34
32
  new ShapePath({
@@ -16,7 +16,6 @@ export const addOvalPcbHole = (
16
16
  soldermaskCutSetting,
17
17
  origin,
18
18
  includeSoldermask,
19
- soldermaskMargin,
20
19
  includeCopper,
21
20
  } = ctx
22
21
  const centerX = hole.x + origin.x
@@ -27,8 +26,8 @@ export const addOvalPcbHole = (
27
26
  const soldermaskPath = createOvalPath({
28
27
  centerX,
29
28
  centerY,
30
- width: hole.hole_width + soldermaskMargin * 2,
31
- height: hole.hole_height + soldermaskMargin * 2,
29
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
30
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0),
32
31
  })
33
32
  project.children.push(
34
33
  new ShapePath({
@@ -16,7 +16,6 @@ export const addPillPcbHole = (
16
16
  soldermaskCutSetting,
17
17
  origin,
18
18
  includeSoldermask,
19
- soldermaskMargin,
20
19
  includeCopper,
21
20
  } = ctx
22
21
  const centerX = hole.x + origin.x
@@ -27,8 +26,8 @@ export const addPillPcbHole = (
27
26
  const soldermaskPath = createPillPath({
28
27
  centerX,
29
28
  centerY,
30
- width: hole.hole_width + soldermaskMargin * 2,
31
- height: hole.hole_height + soldermaskMargin * 2,
29
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
30
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0),
32
31
  })
33
32
  project.children.push(
34
33
  new ShapePath({
@@ -16,7 +16,6 @@ export const addRectPcbHole = (
16
16
  soldermaskCutSetting,
17
17
  origin,
18
18
  includeSoldermask,
19
- soldermaskMargin,
20
19
  includeCopper,
21
20
  } = ctx
22
21
  const centerX = hole.x + origin.x
@@ -27,8 +26,8 @@ export const addRectPcbHole = (
27
26
  const soldermaskPath = createRoundedRectPath({
28
27
  centerX,
29
28
  centerY,
30
- width: hole.hole_width + soldermaskMargin * 2,
31
- height: hole.hole_height + soldermaskMargin * 2,
29
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
30
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0),
32
31
  borderRadius: 0, // no border radius for rect holes
33
32
  })
34
33
  project.children.push(
@@ -16,7 +16,6 @@ export const addRotatedPillPcbHole = (
16
16
  soldermaskCutSetting,
17
17
  origin,
18
18
  includeSoldermask,
19
- soldermaskMargin,
20
19
  includeCopper,
21
20
  } = ctx
22
21
  const centerX = hole.x + origin.x
@@ -28,8 +27,8 @@ export const addRotatedPillPcbHole = (
28
27
  const soldermaskPath = createPillPath({
29
28
  centerX,
30
29
  centerY,
31
- width: hole.hole_width + soldermaskMargin * 2,
32
- height: hole.hole_height + soldermaskMargin * 2,
30
+ width: hole.hole_width + 2 * (hole.soldermask_margin ?? 0),
31
+ height: hole.hole_height + 2 * (hole.soldermask_margin ?? 0),
33
32
  rotation,
34
33
  })
35
34
  project.children.push(
@@ -19,7 +19,7 @@ export const addPcbVia = (via: PcbVia, ctx: ConvertContext): void => {
19
19
  includeCopper,
20
20
  includeSoldermask,
21
21
  connMap,
22
- soldermaskMargin,
22
+ globalCopperSoldermaskMarginAdjustment,
23
23
  includeLayers,
24
24
  } = ctx
25
25
  const centerX = via.x + origin.x
@@ -82,7 +82,8 @@ export const addPcbVia = (via: PcbVia, ctx: ConvertContext): void => {
82
82
 
83
83
  // Add soldermask opening if drawing soldermask
84
84
  if (via.outer_diameter > 0 && includeSoldermask) {
85
- const smRadius = via.outer_diameter / 2 + soldermaskMargin
85
+ const smRadius =
86
+ via.outer_diameter / 2 + globalCopperSoldermaskMarginAdjustment
86
87
  const outer = createCirclePath({
87
88
  centerX,
88
89
  centerY,
@@ -21,7 +21,7 @@ export const addCirclePlatedHole = (
21
21
  includeCopper,
22
22
  includeSoldermask,
23
23
  connMap,
24
- soldermaskMargin,
24
+ globalCopperSoldermaskMarginAdjustment,
25
25
  includeLayers,
26
26
  } = ctx
27
27
  const centerX = platedHole.x + origin.x
@@ -75,7 +75,10 @@ export const addCirclePlatedHole = (
75
75
 
76
76
  // Add soldermask opening if drawing soldermask
77
77
  if (platedHole.outer_diameter > 0 && includeSoldermask) {
78
- const smRadius = platedHole.outer_diameter / 2 + soldermaskMargin
78
+ const smRadius =
79
+ platedHole.outer_diameter / 2 +
80
+ globalCopperSoldermaskMarginAdjustment +
81
+ (platedHole.soldermask_margin ?? 0)
79
82
  const outer = createCirclePath({
80
83
  centerX,
81
84
  centerY,