altium-to-circuit-json 0.0.83 → 0.0.84

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
@@ -465,15 +465,6 @@ function createPcbConversionContext({
465
465
  };
466
466
  }
467
467
 
468
- // lib/schematic/document/constants.ts
469
- var SCHEMATIC_SHEET_ID = "schematic_sheet_altium";
470
- var SCHEMATIC_UNIT_TO_MILLIMETERS = 10.16 / 1.1;
471
- var SCHEMATIC_SHEET_INSET = 5 / SCHEMATIC_UNIT_TO_MILLIMETERS;
472
- var SCHEMATIC_SHEET_WIDTH = 297 / SCHEMATIC_UNIT_TO_MILLIMETERS;
473
- var SCHEMATIC_SHEET_HEIGHT = 210 / SCHEMATIC_UNIT_TO_MILLIMETERS;
474
- var SCHEMATIC_SHEET_INNER_WIDTH = SCHEMATIC_SHEET_WIDTH - SCHEMATIC_SHEET_INSET * 2;
475
- var SCHEMATIC_SHEET_INNER_HEIGHT = SCHEMATIC_SHEET_HEIGHT - SCHEMATIC_SHEET_INSET * 2;
476
-
477
468
  // lib/schematic/geometry/getAveragePoint.ts
478
469
  function getAveragePoint(points) {
479
470
  if (points.length === 0) return { x: 0, y: 0 };
@@ -616,6 +607,15 @@ function unscaleLength(lengthMillimeters, altiumUnitsToMillimetersScale) {
616
607
  }).x;
617
608
  }
618
609
 
610
+ // lib/schematic/document/constants.ts
611
+ var SCHEMATIC_SHEET_ID = "schematic_sheet_altium";
612
+ var SCHEMATIC_UNIT_TO_MILLIMETERS = 10.16 / 1.1;
613
+ var SCHEMATIC_SHEET_INSET = 5 / SCHEMATIC_UNIT_TO_MILLIMETERS;
614
+ var SCHEMATIC_SHEET_WIDTH = 297 / SCHEMATIC_UNIT_TO_MILLIMETERS;
615
+ var SCHEMATIC_SHEET_HEIGHT = 210 / SCHEMATIC_UNIT_TO_MILLIMETERS;
616
+ var SCHEMATIC_SHEET_INNER_WIDTH = SCHEMATIC_SHEET_WIDTH - SCHEMATIC_SHEET_INSET * 2;
617
+ var SCHEMATIC_SHEET_INNER_HEIGHT = SCHEMATIC_SHEET_HEIGHT - SCHEMATIC_SHEET_INSET * 2;
618
+
619
619
  // lib/schematic/document/getPositiveNumber.ts
620
620
  function getPositiveNumber(candidate, fallback) {
621
621
  const parsed = Number(candidate);
@@ -623,11 +623,43 @@ function getPositiveNumber(candidate, fallback) {
623
623
  }
624
624
 
625
625
  // lib/schematic/document/getAltiumSheetDimensions.ts
626
+ var STANDARD_SHEET_SIZES = [
627
+ { width: 1150, height: 760 },
628
+ { width: 1550, height: 1110 },
629
+ { width: 2230, height: 1570 },
630
+ { width: 3150, height: 2230 },
631
+ { width: 4460, height: 3150 },
632
+ { width: 950, height: 750 },
633
+ { width: 1500, height: 950 },
634
+ { width: 2e3, height: 1500 },
635
+ { width: 3200, height: 2e3 },
636
+ { width: 4200, height: 3200 },
637
+ { width: 1100, height: 850 },
638
+ { width: 1400, height: 850 },
639
+ { width: 1700, height: 1100 },
640
+ { width: 990, height: 790 },
641
+ { width: 1540, height: 990 },
642
+ { width: 2060, height: 1560 },
643
+ { width: 3260, height: 2060 },
644
+ { width: 4280, height: 3280 }
645
+ ];
626
646
  function getAltiumSheetDimensions(sheetRecord) {
627
- return {
647
+ const customDimensions = {
628
648
  width: getPositiveNumber(sheetRecord?.getCaseInsensitive("CUSTOMX"), 1e3),
629
649
  height: getPositiveNumber(sheetRecord?.getCaseInsensitive("CUSTOMY"), 800)
630
650
  };
651
+ const sheetStyle = sheetRecord?.getCaseInsensitive("SHEETSTYLE");
652
+ if (sheetRecord?.getCaseInsensitive("USECUSTOMSHEET") === "T" || sheetStyle === void 0) {
653
+ return customDimensions;
654
+ }
655
+ const standardDimensions = STANDARD_SHEET_SIZES[Number(sheetStyle)];
656
+ if (!standardDimensions) {
657
+ throw new RangeError(
658
+ `Unsupported Altium schematic sheet style: ${sheetStyle}`
659
+ );
660
+ }
661
+ const isPortrait = Number(sheetRecord?.getCaseInsensitive("WORKSPACEORIENTATION") ?? 0) !== 0;
662
+ return isPortrait ? { width: standardDimensions.height, height: standardDimensions.width } : standardDimensions;
631
663
  }
632
664
 
633
665
  // lib/schematic/document/createSheetBorder.ts
@@ -650,12 +682,26 @@ function createSheetBorder(sheetRecord, scale5) {
650
682
 
651
683
  // lib/schematic/document/addSchematicSheet.ts
652
684
  function addSchematicSheet(context) {
685
+ const scaledSheetWidth = scaleLength(
686
+ context.sheetDimensions.width,
687
+ context.scale
688
+ );
689
+ const scaledSheetHeight = scaleLength(
690
+ context.sheetDimensions.height,
691
+ context.scale
692
+ );
693
+ const usesCustomSheet = context.sheetRecord?.getCaseInsensitive("USECUSTOMSHEET") === "T";
694
+ const sheetDimensions = usesCustomSheet ? {
695
+ sheet_width: scaledSheetWidth * SCHEMATIC_UNIT_TO_MILLIMETERS,
696
+ sheet_height: scaledSheetHeight * SCHEMATIC_UNIT_TO_MILLIMETERS
697
+ } : {};
653
698
  context.elements.push({
654
699
  type: "schematic_sheet",
655
700
  schematic_sheet_id: SCHEMATIC_SHEET_ID,
656
701
  name: context.options.sheetName ?? "Altium schematic",
657
702
  outline_color: "#334155",
658
- sheet_index: 0
703
+ sheet_index: 0,
704
+ ...sheetDimensions
659
705
  });
660
706
  if (context.options.includeSheetBorder === true) {
661
707
  context.elements.push(createSheetBorder(context.sheetRecord, context.scale));