altium monkey v2026.11.26 · gobblerito
On This Page (7)

Altium Launcher & OutJob Runner

altium-monkey includes Windows automation utilities for discovering and driving a locally installed Altium Designer (X2.EXE), authoring .OutJob files programmatically, generating .PrjScr script projects, and executing OutJob batches through Altium Designer.

Prefer board.fab() Whenever Possible

Before automating desktop Altium Designer, check whether you actually need X2.EXE:

Outputboard.fab() (Headless)AltiumOutJobRunner (Windows X2.EXE)
Gerber X2 / X1Yes — cross-platform, headless, deterministicOnly when capturing Altium reference output
NC Drill (Excellon)YesOnly for Altium reference output
IPC-2581BYesOnly for Altium reference output
PCB SVG / Schematic SVG & PNGYes (board.to_svg, schdoc.to_svg, to_paint_png)Rarely needed
Pick & Place / PCB & Schematic BOMYes (fab.to_pnp, fab.to_bom, design.to_bom)Only when an Altium Excel/template BOM is required
ODB++, Altium STEP exportNot produced nativelyYes (GeneratedFiles container; see limitations below)
PDF/Publish containers, schematic/PCB printer outputs, Draftsman printsUse native SVG/PNG (to_svg, to_paint_png) where SVG/PNG fitsNot supported reliably (use Altium OutJob editor or Project Releaser)

board.fab() runs in-process in milliseconds on Windows, Linux, and macOS with no license checkout, no GUI windows, and no modal dialogs. Reserve AltiumLauncher and AltiumOutJobRunner for Altium-only outputs or reference captures against desktop Altium Designer.


Public Modules & Import Paths

None of the launcher/OutJob classes are re-exported at the root altium_monkey package; import them from their dedicated submodules:

ModuleSymbolsPurpose
altium_monkey.altium_launcherAltiumLauncher, AltiumProcessInfoDiscover, launch, query, and terminate local X2.EXE installs
altium_monkey.altium_outjobAltiumOutJob, altium_expr, altium_literal, OutJobConfigRecord, OutJobOutputSpec, IPC2581Output, GerberOutput, GerberX2Output, NCDrillOutput, ODBOutput, PickPlaceOutput, BomPartTypeOutput, ExportStepOutput, SchematicPrintOutput, PcbDrawingOutputParse, edit, and build .OutJob INI files
altium_monkey.altium_outjob_runnerAltiumOutJobRunner, OutJobRunRequest, OutJobRunResult, OutJobNormalizationResult, normalize_outjob_generated_pathsExecute .OutJob files through local Altium Designer via a generated .pas script
altium_monkey.altium_prjscrAltiumPrjScrGenerate minimal .PrjScr script project files referencing .pas scripts
altium_monkey.altium_prjpcbAltiumPrjPcb.get_outjob_paths(), AltiumPrjPcb.outjob(name=None) → AltiumPrjPcbOutJobDiscover project OutJobs and run them directly from a .PrjPcb

1. Discovering & Controlling X2.EXE (AltiumLauncher)

AltiumLauncher scans standard Windows install directories (C:\Program Files\Altium\AD* and C:\Program Files (x86)\Altium\AD*, matching AD<digits> or ADDevelop) and sorts installations by the PE VS_FIXEDFILEINFO version of X2.EXE:

python
from altium_monkey.altium_launcher import AltiumLauncher

launcher = AltiumLauncher()
print("Selected X2.EXE:", launcher.executable)

if launcher.is_running():
    print("Running processes:", launcher.get_running_processes())

# Launch a script project / procedure
proc = launcher.launch_script(
    prjscr_path="run_outjob.PrjScr",
    script_name="run_outjob.pas",
    procedure_name="RunOutJob",
)

2. Authoring & Editing .OutJob Files (AltiumOutJob)

AltiumOutJob parses and serializes Altium's INI-style .OutJob format and offers typed output specifications for common fabrication, assembly, and documentation jobs:

python
from altium_monkey.altium_outjob import (
    AltiumOutJob,
    GerberX2Output,
    IPC2581Output,
    NCDrillOutput,
    ODBOutput,
    altium_expr,
    altium_literal,
)

outjob = AltiumOutJob()
outjob.add_output(GerberX2Output(name="Gerber X2"))
outjob.add_output(NCDrillOutput(name="NC Drill"))
outjob.add_output(IPC2581Output(name="IPC-2581B"))
outjob.add_output(ODBOutput(name="ODB++"))
outjob.save("fab.OutJob")

3. Running OutJobs (AltiumOutJobRunner & AltiumPrjPcb.outjob())

AltiumOutJobRunner automates desktop Altium Designer by generating an Altium script (run_outjob.pas + run_outjob.PrjScr) that opens the .PrjPcb, runs DM_Compile, opens the .OutJob, invokes WorkSpaceManager:GenerateReport(ObjectKind=OutputBatch, Action=Run), and writes a status sentinel file (DONE:0) once Altium returns control.

python
from altium_monkey.altium_outjob_runner import AltiumOutJobRunner
from altium_monkey.altium_prjpcb import AltiumPrjPcb

# Option A: Directly through AltiumPrjPcb (using a disposable copy of the project)
project = AltiumPrjPcb("work_copy/board.PrjPcb")
result = project.outjob("fab.OutJob").run(
    timeout_seconds=300,
    stage_outjob_copy=False,
    kill_after_run=False,
)
print(result.success, result.error_count)

# Option B: Directly via AltiumOutJobRunner
runner = AltiumOutJobRunner()
result = runner.run(
    "work_copy/board.PrjPcb",
    outjob_path="work_copy/fab.OutJob",
    stage_outjob_copy=False,
    timeout_seconds=300,
)

4. Known Limitations And Operational Hazards

Desktop Altium automation inherits every constraint of GUI-driven X2.EXE. Plan around these verified behaviors:

  1. Windows + licensed local X2.EXE required: There is no headless Linux or macOS Altium runtime. Interactive desktop access is required so Altium can create its GUI window and execute script actions.
  2. Modal dialogs stall runs until timeout_seconds: The generated script uses fixed Sleep(500..1000) waits around OpenObject, DM_Compile, OpenDocument, and GenerateReport. Any Altium modal prompt (license dialog, missing library warning, save confirmation, version upgrade dialog, or Gerber/CAMtastic auto-open prompt) blocks execution until timeout_seconds (default 300 s) expires.
  3. PDF / Publish / Printer containers are NOT reliably supported (GeneratedFiles-only scope):
    • Verified scope is folder-based GeneratedFiles manufacturing containers (Gerber, NC Drill, ODB++, IPC-2581, and some netlist outputs), and exact behavior still depends on the installed Altium Designer version.
    • PDF/Publish containers, schematic prints, PCB prints, printer outputs, and Draftsman outputs are not supported reliably. GenerateReport(ObjectKind=OutputBatch, Action=Run) does not iterate every output container in a mixed-media .OutJob, and Altium's legacy scripting interface is largely undocumented and changes between Altium releases.
    • OutJobRunResult.success == True only confirms that the runner script wrote its DONE:0 sentinel without a script exception — Altium can still silently emit zero files. Always verify the expected output files exist on disk after a run.
    • For PDF or print outputs, either use altium-monkey's native cross-platform renderers (schdoc.to_svg(), schdoc.to_paint_png(), board.to_svg(), board.to_layer_svgs()), generate each container in Altium's OutJob editor, or use Altium's Project Releaser (which can target a local folder or a connected Workspace; Altium's own documentation notes that direct OutJob generation is per container with no single batch command across all containers — see Preparing Manufacturing Data with Output Jobs and Design Project Release).
    • Tracked public reports: #33, #34, and #61.
  4. stage_outjob_copy=True vs. .PrjPcb membership hazard: Altium expects the .OutJob to be a registered [DocumentN] member of the .PrjPcb. When stage_outjob_copy=True (the default on run()), the runner writes a temporary copy (__outjob_run_<rand>.OutJob) that is not registered in the .PrjPcb, which can cause Altium to silently emit zero files. For reliable automation, copy the project directory into a disposable working folder and pass stage_outjob_copy=False against the registered .OutJob.
  5. kill_after_run=True has machine-wide blast radius: AltiumLauncher.kill() runs taskkill /F /IM X2.EXE, terminating every Altium Designer instance on the machine. As a safety guard, kill_after_run=True refuses to start if any X2.EXE is already running. Conversely, with kill_after_run=False, Altium stays open with the project loaded (and closing it manually afterward may prompt to save modified documents after DM_Compile).
  6. Strictly sequential execution: run_many() runs requests one at a time and reuses the same run_outjob.pas / run_outjob.PrjScr filenames inside the runner's script directory; do not invoke multiple runners concurrently on the same machine. Pass stage_outjob_copy=False on OutJobRunRequest when running registered project .OutJob files inside a disposable copy.
  7. Slow failure on bad launch: If X2.EXE exits with a non-zero launch code before writing the sentinel file, the runner still polls until timeout_seconds elapses rather than failing immediately.
altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)