altium-to-circuit-json 0.0.76 → 0.0.77

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
@@ -879,7 +879,7 @@ function renderTextRecord({
879
879
  }) {
880
880
  const kind = record.recordKind;
881
881
  const scale5 = context.scale;
882
- if (kind === "4" || kind === "25" || kind === "34" || kind === "41") {
882
+ if (kind === "4" || kind === "25" || kind === "32" || kind === "33" || kind === "34" || kind === "41") {
883
883
  if (options.includeText === false) return [];
884
884
  if (record.getBoolean("ISHIDDEN") && !options.includeHidden) return [];
885
885
  const text = record.getDecoded("TEXT") ?? record.getDecoded("NAME") ?? record.getDecoded("DESIGNATOR");
@@ -1633,6 +1633,124 @@ function renderSchematicImageRecord({
1633
1633
  ];
1634
1634
  }
1635
1635
 
1636
+ // lib/schematic/rendering/renderSheetEntry.ts
1637
+ function renderSheetEntry({
1638
+ context,
1639
+ index,
1640
+ options,
1641
+ record
1642
+ }) {
1643
+ const sheetSymbol = context.document.getParent(record);
1644
+ const sheetLocation = sheetSymbol ? getLocation(sheetSymbol) : void 0;
1645
+ if (!sheetSymbol || sheetSymbol.recordKind !== "15" || !sheetLocation) {
1646
+ return [];
1647
+ }
1648
+ const sheetWidth = Math.max(
1649
+ getCoordinateOrFallback({ record: sheetSymbol, key: "XSIZE", fallback: 1 }),
1650
+ 1
1651
+ );
1652
+ const sheetHeight = Math.max(
1653
+ getCoordinateOrFallback({ record: sheetSymbol, key: "YSIZE", fallback: 1 }),
1654
+ 1
1655
+ );
1656
+ const distance = Math.max(record.getNumber("DISTANCEFROMTOP") ?? 0, 0) * 10;
1657
+ const rawSide = Math.round(record.getNumber("SIDE") ?? 0);
1658
+ const side = rawSide === 1 || rawSide === 2 || rawSide === 3 ? rawSide : 0;
1659
+ const point = side === 1 ? { x: sheetLocation.x + sheetWidth, y: sheetLocation.y - distance } : side === 2 ? { x: sheetLocation.x + distance, y: sheetLocation.y } : side === 3 ? {
1660
+ x: sheetLocation.x + distance,
1661
+ y: sheetLocation.y - sheetHeight
1662
+ } : { x: sheetLocation.x, y: sheetLocation.y - distance };
1663
+ const points = side === 1 ? [
1664
+ { x: point.x, y: point.y + 4 },
1665
+ { x: point.x - 7, y: point.y },
1666
+ { x: point.x, y: point.y - 4 }
1667
+ ] : side === 2 ? [
1668
+ { x: point.x - 4, y: point.y },
1669
+ { x: point.x, y: point.y - 7 },
1670
+ { x: point.x + 4, y: point.y }
1671
+ ] : side === 3 ? [
1672
+ { x: point.x - 4, y: point.y },
1673
+ { x: point.x, y: point.y + 7 },
1674
+ { x: point.x + 4, y: point.y }
1675
+ ] : [
1676
+ { x: point.x, y: point.y + 4 },
1677
+ { x: point.x + 7, y: point.y },
1678
+ { x: point.x, y: point.y - 4 }
1679
+ ];
1680
+ const elements = [
1681
+ {
1682
+ type: "schematic_path",
1683
+ schematic_path_id: `schematic_sheet_entry_altium_${index}`,
1684
+ schematic_sheet_id: SCHEMATIC_SHEET_ID,
1685
+ points: points.map((entryPoint) => scalePoint(entryPoint, context.scale)),
1686
+ stroke_width: Math.max(scaleLength(1, context.scale), 0.05),
1687
+ stroke_color: "#840000",
1688
+ fill_color: "#ffffc2",
1689
+ is_filled: true,
1690
+ is_dashed: false
1691
+ }
1692
+ ];
1693
+ const name = record.getDecoded("NAME");
1694
+ if (!name || options.includeText === false) return elements;
1695
+ const fontId = Math.max(Math.round(record.getNumber("TEXTFONTID") ?? 1), 1);
1696
+ const fontSize = Math.max(
1697
+ Number(context.sheetRecord?.getCaseInsensitive(`SIZE${fontId}`) ?? 9),
1698
+ 1
1699
+ );
1700
+ const textLocation = side === 0 ? { x: point.x + 9, y: point.y } : side === 1 ? { x: point.x - 9, y: point.y } : side === 2 ? { x: point.x, y: point.y - 9 } : { x: point.x, y: point.y + 9 };
1701
+ const anchor = side === 0 ? "center_left" : side === 1 ? "center_right" : side === 2 ? "top_center" : "bottom_center";
1702
+ elements.push(
1703
+ createDirectText({
1704
+ id: `schematic_sheet_entry_text_altium_${index}`,
1705
+ text: name,
1706
+ location: textLocation,
1707
+ fontSize,
1708
+ color: "#840000",
1709
+ scale: context.scale,
1710
+ ccwRotationDegrees: 0,
1711
+ anchor
1712
+ })
1713
+ );
1714
+ return elements;
1715
+ }
1716
+
1717
+ // lib/schematic/rendering/renderSheetSymbol.ts
1718
+ function renderSheetSymbol({
1719
+ context,
1720
+ index,
1721
+ record
1722
+ }) {
1723
+ const location = getLocation(record);
1724
+ if (!location) return [];
1725
+ const width = Math.max(
1726
+ getCoordinateOrFallback({ record, key: "XSIZE", fallback: 1 }),
1727
+ 1
1728
+ );
1729
+ const height = Math.max(
1730
+ getCoordinateOrFallback({ record, key: "YSIZE", fallback: 1 }),
1731
+ 1
1732
+ );
1733
+ return [
1734
+ {
1735
+ type: "schematic_rect",
1736
+ schematic_rect_id: `schematic_sheet_symbol_altium_${index}`,
1737
+ schematic_sheet_id: SCHEMATIC_SHEET_ID,
1738
+ center: scalePoint(
1739
+ { x: location.x + width / 2, y: location.y - height / 2 },
1740
+ context.scale
1741
+ ),
1742
+ width: scaleLength(width, context.scale),
1743
+ height: scaleLength(height, context.scale),
1744
+ rotation: 0,
1745
+ stroke_width: Math.max(scaleLength(1, context.scale), 0.05),
1746
+ color: "#840000",
1747
+ is_filled: true,
1748
+ fill_color: "#ffffc2",
1749
+ is_dashed: false
1750
+ }
1751
+ ];
1752
+ }
1753
+
1636
1754
  // lib/schematic/rendering/convertSchematicRecord.ts
1637
1755
  function convertSchematicRecord({
1638
1756
  record,
@@ -1649,6 +1767,10 @@ function convertSchematicRecord({
1649
1767
  if (record instanceof AltiumSchImageRecord) {
1650
1768
  return renderSchematicImageRecord({ context, index, record });
1651
1769
  }
1770
+ if (kind === "15") return renderSheetSymbol({ context, index, record });
1771
+ if (kind === "16") {
1772
+ return renderSheetEntry({ context, index, options, record });
1773
+ }
1652
1774
  const primitive = renderPrimitiveRecord({
1653
1775
  record,
1654
1776
  index,