Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

OriginalCircuit.Altium.TestDataGenerator

Altium Designer DelphiScript project for generating comprehensive test files for the [OriginalCircuit.Altium](https://github.com/issus/AltiumSharp) library. Produces PcbLib and SchLib files with known primitive values, plus JSON exports for ground truth comparison in unit tests.

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

OriginalCircuit.Altium.TestDataGenerator

Altium Designer DelphiScript project for generating comprehensive test files for the OriginalCircuit.Altium library. Produces PcbLib and SchLib files with known primitive values, plus JSON exports for ground truth comparison in unit tests.

Prerequisites

  • Altium Designer (AD25 or later recommended)
  • The scripts run inside Altium's built-in scripting engine (DelphiScript)

Project Files

File Description
TestDataGenerator.pas Generates PcbLib and SchLib test files with comprehensive primitive coverage
FileToJsonConverter.pas Converts any open Altium file (PcbLib, SchLib, SchDoc, PcbDoc) to JSON
TestDataGenerator.PrjScr Altium script project for the generator (standalone)
FileToJsonConverter.PrjScr Altium script project for the JSON converter (standalone)
TestDataGenerator.PrjPcb Combined Altium PCB project containing both scripts
RunGenerator.bat Batch file for automated/headless test data generation
API/ 100+ CSV files documenting Altium API interfaces (IPCB_, ISch_)
step/ STEP 3D model files used by the BODY_3D_STEP test footprint

Usage

Generating Test Files

  1. Open the project in Altium Designer: File > Open Project > TestDataGenerator.PrjPcb
  2. Open the script: Double-click TestDataGenerator.pas
  3. Run a procedure: DXP > Run Script (or File > Run Script)
  4. Select one of:
    • RunGenerateAll — Generate all test files (combined + individual)
    • RunGeneratePcbLib — Generate only PCB library (combined + individual)
    • RunGenerateSchLib — Generate only Schematic library (combined + individual)

Converting Existing Files to JSON

  1. Open the project: File > Open Project > FileToJsonConverter.PrjScr
  2. Open the Altium file you want to convert (PcbLib, SchLib, SchDoc, or PcbDoc)
  3. Run a procedure: DXP > Run Script
  4. Select FileToJsonConverter.pas and one of:
    • RunExportCurrentPcbLib — Export currently open PCB library to JSON
    • RunExportCurrentSchLib — Export currently open Schematic library to JSON
    • RunExportCurrentSchDoc — Export currently open schematic document to JSON
    • RunExportCurrentPcbDoc — Export currently open PCB document to JSON

JSON files are saved alongside the source file with a .json extension.

Command Line (Automated)

batch
REM Adjust the Altium Designer and project paths for your installation
"C:\Program Files\Altium\AD25\X2.EXE" -RScriptingSystem:RunScript(ProjectName="C:\path\to\TestDataGenerator.PrjPcb"^|ProcName="RunGenerateAll")

Or use the provided RunGenerator.bat (edit the paths at the top of the file first).

Generated Output

The test data generator writes output to the path configured in the script. The default structure is:

pascal
<OutputDir>/
    TestPcbLib.PcbLib          Combined PCB library with all test footprints
    TestPcbLib.json            JSON export of combined PCB library
    TestSchLib.SchLib          Combined schematic library with all test symbols
    TestSchLib.json            JSON export of combined schematic library
    Individual/
        PCB/
            PAD_TH_ROUND.PcbLib    One footprint per file
            PAD_TH_ROUND.json
            PAD_SMD_ROUNDED.PcbLib
            PAD_SMD_ROUNDED.json
            ...
        SchLib/
            RESISTOR.SchLib        One symbol per file
            RESISTOR.json
            CIRCLE_FILLED.SchLib
            CIRCLE_FILLED.json
            ...

Test Coverage

PCB Footprints

Pad Types

  • PAD_TH_ROUND — Through-hole round pad
  • PAD_TH_RECTANGULAR — Through-hole rectangular pad
  • PAD_TH_OCTAGONAL — Through-hole octagonal pad
  • PAD_SMD_RECTANGULAR — SMD rectangular pad
  • PAD_SMD_ROUNDED — SMD rounded rectangular pad
  • PAD_ROTATED — Pad with 45-degree rotation

Basic Primitives

  • TRACKS_MULTILAYER — Tracks on Top, Bottom, and Overlay layers
  • ARCS_TEST — Arcs with various angles (90, 180, 360 degrees)
  • FILLS_TEST — Fill regions with rotation
  • REGIONS_TEST — Region objects
  • COMPLEX_FOOTPRINT — Multiple primitives combined

Text Objects

  • TEXT_TEST — Text objects (normal, rotated, mirrored)
  • TEXT_TRUETYPE — TrueType font text (Arial, Times New Roman, Courier)
  • TEXT_INVERTED — Inverted (knockout) text
  • TEXT_BARCODE — Barcode text (Code39)

Polygons

  • POLYGON_SOLID — Solid copper pour polygon
  • POLYGON_HATCHED — Hatched copper pour polygon
  • REGION_CUTOUT — Cutout region for polygon pours

Advanced Objects

  • BODY_3D — 3D extruded component body
  • BODY_3D_STEP — 3D body loaded from STEP file
  • KEEPOUT_REGION — Keepout region and track
  • DIMENSION_LINEAR — Linear dimension object

Schematic Symbols

Component Symbols

  • RESISTOR — Basic 2-pin passive with rectangle body
  • CAPACITOR — Capacitor with parallel plates
  • OPAMP — 5-pin operational amplifier with triangle body
  • CONNECTOR_4 — 4-pin connector
  • LED — LED with anode/cathode and light arrows
  • TRANSISTOR_NPN — NPN transistor with B/C/E pins

Shape Test Symbols

  • CIRCLE_FILLED — Filled circle (ellipse with equal radii)
  • CIRCLE_OUTLINE — Outline circle
  • ELLIPSE_TEST — Ellipse with different X/Y radii
  • ROUNDRECT_TEST — Rounded rectangle
  • ARC_FULL — Full 360-degree arc
  • POLYLINE_TEST — Open polyline with 4 vertices (zigzag pattern)
  • POLYGON_TEST — Closed polygon with 4 vertices (diamond shape)
  • TEXTFRAME_TEST — Text frame with border

JSON Export Format

PCB Library

json
{
  "metadata": {
    "exportType": "PcbLib",
    "fileName": "TestPcbLib.PcbLib",
    "exportedBy": "AltiumSharp TestDataGenerator",
    "version": "1.0"
  },
  "footprints": [
    {
      "name": "PAD_TH_ROUND",
      "description": "Through-hole round pad test",
      "height": {...},
      "primitives": [
        {
          "objectType": "Pad",
          "name": "1",
          "x": {"internal": 0, "mils": 0, "mm": 0},
          "y": {"internal": 0, "mils": 0, "mm": 0},
          "topXSize": {"internal": 600000, "mils": 60, "mm": 1.524},
          "holeSize": {"internal": 300000, "mils": 30, "mm": 0.762},
          "topShape": 1,
          "rotation": 0,
          "layer": 74,
          "plated": true
        }
      ]
    }
  ]
}

Schematic Library

json
{
  "metadata": {
    "exportType": "SchLib",
    "fileName": "TestSchLib.SchLib",
    "exportedBy": "AltiumSharp TestDataGenerator",
    "version": "1.0"
  },
  "symbols": [
    {
      "objectType": "Component",
      "designator": "R?",
      "comment": "Resistor",
      "libReference": "RESISTOR",
      "description": "Basic 2-pin resistor symbol",
      "primitives": [
        {
          "objectType": "Pin",
          "name": "P1",
          "designator": "1",
          "x": -400,
          "y": 0,
          "orientation": 2,
          "electrical": 7
        }
      ]
    }
  ]
}

Coordinate Systems

PCB Coordinates

  • Internal units: 10,000 per mil (1 mil = 0.001 inch)
  • All coordinates exported as: {"internal": N, "mils": N/10000, "mm": N/393701}

Schematic Coordinates

  • Internal units: 10 per mil (DXP units)
  • Exported as raw integer values

Extending the Generator

To add new test primitives:

  1. Add a creation procedure (e.g., CreatePcbPad, CreateSchPin)
  2. Add a JSON export procedure (e.g., ExportPcbPadToJson)
  3. Call from the generator procedure (GeneratePcbLibTestFootprints, etc.)
  4. Update the iterator filter in the export procedure if needed
  5. For individual file generation, add a CreateFootprint_* procedure and call from GenerateIndividualPcbLibFiles

STEP Files

The step/ directory contains 3D model files used by the BODY_3D_STEP test footprint:

  • PSEMI QFN-24 4x4.step — QFN-24 package (used by default)
  • RES AXIAL TH D1.6 L3.6 R0.01 T5.step — Axial resistor
  • AMD FCBGA-676 FFVB676.step — BGA package
  • STM UFQFPN-48 7X7 A0B9.step — QFP package

API Reference CSVs

The API/ directory contains 100+ CSV files documenting Altium Designer's scripting API interfaces. Each CSV lists the properties and methods available on a given interface (e.g., IPCB_Pad.csv, ISch_Pin.csv). These were extracted from Altium's online API documentation and are useful for:

  • Discovering which properties are available for each object type
  • Planning new test coverage for additional primitives
  • Cross-referencing Altium's internal property names with binary file format fields

Integration with OriginalCircuit.Altium

Use the generated files and JSON exports for:

  1. Unit Testing — Compare OriginalCircuit.Altium parsed values against JSON ground truth
  2. Reverse Engineering — Discover how Altium stores different primitive types in binary
  3. Format Discovery — Compare JSON exports across different Altium Designer versions
  4. Validation — Verify round-trip read/write operations preserve all data
  5. Individual Test Cases — Use single-footprint/symbol files for targeted unit tests

License

MIT