altium-to-circuit-json 0.0.78 → 0.0.80

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 CHANGED
@@ -5288,32 +5288,68 @@ function getMeasurement(record, key) {
5288
5288
  return parseAltiumMeasurementToMils2(record.getCaseInsensitive(key));
5289
5289
  }
5290
5290
 
5291
- // lib/pcb/annotations/convertPcbDimension.ts
5292
- function convertPcbDimension({
5293
- record,
5294
- recordIndex
5295
- }) {
5291
+ // lib/pcb/annotations/getDimensionAxis.ts
5292
+ import { applyToPoint as applyToPoint9, rotateDEG as rotateDEG4 } from "transformation-matrix";
5293
+ function getDimensionAxis(record) {
5294
+ const angleDegrees = record.getNumber("ANGLE");
5295
+ if (angleDegrees !== void 0 && Number.isFinite(angleDegrees)) {
5296
+ return applyToPoint9(rotateDEG4(angleDegrees), { x: 1, y: 0 });
5297
+ }
5296
5298
  const start = record.start;
5297
5299
  const end = record.end;
5298
- if (!start || !end) return void 0;
5300
+ if (!start || !end) return { x: 1, y: 0 };
5299
5301
  const deltaX = end.x - start.x;
5300
5302
  const deltaY = end.y - start.y;
5301
- const lengthMils = Math.hypot(deltaX, deltaY);
5303
+ const distance = Math.hypot(deltaX, deltaY);
5304
+ if (distance === 0) return { x: 1, y: 0 };
5305
+ return { x: deltaX / distance, y: deltaY / distance };
5306
+ }
5307
+
5308
+ // lib/pcb/annotations/getPcbDimensionProjection.ts
5309
+ function getPcbDimensionProjection(record) {
5310
+ const referenceStart = record.start;
5311
+ const referenceEnd = record.end;
5312
+ if (!referenceStart || !referenceEnd) return void 0;
5313
+ const axis = getDimensionAxis(record);
5314
+ const deltaX = referenceEnd.x - referenceStart.x;
5315
+ const deltaY = referenceEnd.y - referenceStart.y;
5316
+ const signedLengthMils = deltaX * axis.x + deltaY * axis.y;
5317
+ const lengthMils = Math.abs(signedLengthMils);
5302
5318
  if (lengthMils === 0) return void 0;
5319
+ return {
5320
+ axis,
5321
+ lengthMils,
5322
+ projectedEnd: {
5323
+ x: referenceStart.x + axis.x * signedLengthMils,
5324
+ y: referenceStart.y + axis.y * signedLengthMils
5325
+ },
5326
+ referenceEnd,
5327
+ referenceStart
5328
+ };
5329
+ }
5330
+
5331
+ // lib/pcb/annotations/convertPcbDimension.ts
5332
+ function convertPcbDimension({
5333
+ record,
5334
+ recordIndex
5335
+ }) {
5336
+ const projection = getPcbDimensionProjection(record);
5337
+ if (!projection) return void 0;
5338
+ const { axis, lengthMils, projectedEnd, referenceStart } = projection;
5303
5339
  const perpendicular = {
5304
- x: -deltaY / lengthMils,
5305
- y: deltaX / lengthMils
5340
+ x: -axis.y,
5341
+ y: axis.x
5306
5342
  };
5307
- const lineAnchor = record.dimensionLineAnchor ?? start;
5308
- const signedOffsetMils = (lineAnchor.x - start.x) * perpendicular.x + (lineAnchor.y - start.y) * perpendicular.y;
5343
+ const lineAnchor = record.dimensionLineAnchor ?? referenceStart;
5344
+ const signedOffsetMils = (lineAnchor.x - referenceStart.x) * perpendicular.x + (lineAnchor.y - referenceStart.y) * perpendicular.y;
5309
5345
  const offsetSign = signedOffsetMils < 0 ? -1 : 1;
5310
5346
  return {
5311
5347
  type: "pcb_fabrication_note_dimension",
5312
5348
  pcb_fabrication_note_dimension_id: `pcb_fabrication_note_dimension_altium_${recordIndex}`,
5313
5349
  pcb_component_id: BOARD_GRAPHICS_COMPONENT_ID,
5314
5350
  layer: mapMechanicalLayer(getRecordLayer(record)),
5315
- from: toMillimeterPoint(start),
5316
- to: toMillimeterPoint(end),
5351
+ from: toMillimeterPoint(referenceStart),
5352
+ to: toMillimeterPoint(projectedEnd),
5317
5353
  text: getDimensionText(record, lengthMils),
5318
5354
  offset_distance: milsToMillimeters(Math.abs(signedOffsetMils)),
5319
5355
  offset_direction: {
@@ -5327,6 +5363,45 @@ function convertPcbDimension({
5327
5363
  };
5328
5364
  }
5329
5365
 
5366
+ // lib/pcb/annotations/convertPcbDimensionExtensionPath.ts
5367
+ var REFERENCE_ALIGNMENT_TOLERANCE_MILS = 1e-6;
5368
+ function convertPcbDimensionExtensionPath({
5369
+ record,
5370
+ recordIndex
5371
+ }) {
5372
+ const projection = getPcbDimensionProjection(record);
5373
+ if (!projection) return void 0;
5374
+ const { projectedEnd, referenceEnd } = projection;
5375
+ const referenceGapMils = Math.hypot(
5376
+ referenceEnd.x - projectedEnd.x,
5377
+ referenceEnd.y - projectedEnd.y
5378
+ );
5379
+ if (referenceGapMils <= REFERENCE_ALIGNMENT_TOLERANCE_MILS) return void 0;
5380
+ return {
5381
+ type: "pcb_fabrication_note_path",
5382
+ pcb_fabrication_note_path_id: `pcb_fabrication_note_path_altium_dimension_${recordIndex}_reference_extension`,
5383
+ pcb_component_id: BOARD_GRAPHICS_COMPONENT_ID,
5384
+ layer: mapMechanicalLayer(getRecordLayer(record)),
5385
+ route: [referenceEnd, projectedEnd].map(toMillimeterPoint),
5386
+ stroke_width: milsToMillimeters(record.lineWidthMils ?? 8),
5387
+ color: FABRICATION_NOTE_COLOR
5388
+ };
5389
+ }
5390
+
5391
+ // lib/pcb/annotations/convertPcbDimensionElements.ts
5392
+ function convertPcbDimensionElements({
5393
+ record,
5394
+ recordIndex
5395
+ }) {
5396
+ const dimension = convertPcbDimension({ record, recordIndex });
5397
+ if (!dimension) return [];
5398
+ const extensionPath = convertPcbDimensionExtensionPath({
5399
+ record,
5400
+ recordIndex
5401
+ });
5402
+ return extensionPath ? [dimension, extensionPath] : [dimension];
5403
+ }
5404
+
5330
5405
  // lib/pcb/annotations/convertPcbFabricationNotePath.ts
5331
5406
  import {
5332
5407
  AltiumTrackRecord as AltiumTrackRecord6,
@@ -5724,10 +5799,10 @@ import {
5724
5799
  import { normalizeAltiumAngle } from "altiumts";
5725
5800
 
5726
5801
  // lib/pcb/pads/getRotatedHoleOffset.ts
5727
- import { applyToPoint as applyToPoint9, rotateDEG as rotateDEG4 } from "transformation-matrix";
5802
+ import { applyToPoint as applyToPoint10, rotateDEG as rotateDEG5 } from "transformation-matrix";
5728
5803
  function getRotatedHoleOffset(geometry) {
5729
- const padToPcbTransform = rotateDEG4(geometry.ccwRotationDegrees);
5730
- return applyToPoint9(padToPcbTransform, {
5804
+ const padToPcbTransform = rotateDEG5(geometry.ccwRotationDegrees);
5805
+ return applyToPoint10(padToPcbTransform, {
5731
5806
  x: geometry.holeOffsetXMils,
5732
5807
  y: geometry.holeOffsetYMils
5733
5808
  });
@@ -6076,8 +6151,7 @@ function convertPcbRecords(context) {
6076
6151
  }
6077
6152
  if (record instanceof AltiumDimensionRecord) {
6078
6153
  if (options.includeDimensions === false) continue;
6079
- const dimension = convertPcbDimension({ record, recordIndex });
6080
- if (dimension) elements.push(dimension);
6154
+ elements.push(...convertPcbDimensionElements({ record, recordIndex }));
6081
6155
  continue;
6082
6156
  }
6083
6157
  if (options.includeDimensions !== false && isExplodedPcbDimensionGraphic(document, record)) {