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:
| Output | board.fab() (Headless) | AltiumOutJobRunner (Windows X2.EXE) |
|---|---|---|
| Gerber X2 / X1 | Yes — cross-platform, headless, deterministic | Only when capturing Altium reference output |
| NC Drill (Excellon) | Yes | Only for Altium reference output |
| IPC-2581B | Yes | Only for Altium reference output |
| PCB SVG / Schematic SVG & PNG | Yes (board.to_svg, schdoc.to_svg, to_paint_png) | Rarely needed |
| Pick & Place / PCB & Schematic BOM | Yes (fab.to_pnp, fab.to_bom, design.to_bom) | Only when an Altium Excel/template BOM is required |
| ODB++, Altium STEP export | Not produced natively | Yes (GeneratedFiles container; see limitations below) |
| PDF/Publish containers, schematic/PCB printer outputs, Draftsman prints | Use native SVG/PNG (to_svg, to_paint_png) where SVG/PNG fits | Not 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:
| Module | Symbols | Purpose |
|---|---|---|
altium_monkey.altium_launcher | AltiumLauncher, AltiumProcessInfo | Discover, launch, query, and terminate local X2.EXE installs |
altium_monkey.altium_outjob | AltiumOutJob, altium_expr, altium_literal, OutJobConfigRecord, OutJobOutputSpec, IPC2581Output, GerberOutput, GerberX2Output, NCDrillOutput, ODBOutput, PickPlaceOutput, BomPartTypeOutput, ExportStepOutput, SchematicPrintOutput, PcbDrawingOutput | Parse, edit, and build .OutJob INI files |
altium_monkey.altium_outjob_runner | AltiumOutJobRunner, OutJobRunRequest, OutJobRunResult, OutJobNormalizationResult, normalize_outjob_generated_paths | Execute .OutJob files through local Altium Designer via a generated .pas script |
altium_monkey.altium_prjscr | AltiumPrjScr | Generate minimal .PrjScr script project files referencing .pas scripts |
altium_monkey.altium_prjpcb | AltiumPrjPcb.get_outjob_paths(), AltiumPrjPcb.outjob(name=None) → AltiumPrjPcbOutJob | Discover 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:
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",
)- Set the
ALTIUM_PREFERRED_VERSIONenvironment variable (for example"25"or"AD25"— note the"AD"prefix strip is case-sensitive) to pin a specific installed major version. If the preferred version is not found,AltiumLauncherlogs a warning and falls back to the newest detected build. - Calling
AltiumLauncheron non-Windows raisesOSError; if noX2.EXEis found, it raisesFileNotFoundError.
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:
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")- Use
altium_expr(...)when writing Altium parameter expressions (leading=) andaltium_literal(...)for literal string values. - Use
normalize_outjob_generated_paths(outjob_path, ...)fromaltium_monkey.altium_outjob_runnerto rewrite absolute Windows output paths to portable relative paths (Altium=variable expressions and UNC\\server\sharepaths are preserved unchanged).
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.
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:
- Windows + licensed local
X2.EXErequired: 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. - Modal dialogs stall runs until
timeout_seconds: The generated script uses fixedSleep(500..1000)waits aroundOpenObject,DM_Compile,OpenDocument, andGenerateReport. Any Altium modal prompt (license dialog, missing library warning, save confirmation, version upgrade dialog, or Gerber/CAMtastic auto-open prompt) blocks execution untiltimeout_seconds(default300s) expires. - PDF / Publish / Printer containers are NOT reliably supported (
GeneratedFiles-only scope):- Verified scope is folder-based
GeneratedFilesmanufacturing 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 == Trueonly confirms that the runner script wrote itsDONE:0sentinel 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.
- Verified scope is folder-based
stage_outjob_copy=Truevs..PrjPcbmembership hazard: Altium expects the.OutJobto be a registered[DocumentN]member of the.PrjPcb. Whenstage_outjob_copy=True(the default onrun()), 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 passstage_outjob_copy=Falseagainst the registered.OutJob.kill_after_run=Truehas machine-wide blast radius:AltiumLauncher.kill()runstaskkill /F /IM X2.EXE, terminating every Altium Designer instance on the machine. As a safety guard,kill_after_run=Truerefuses to start if anyX2.EXEis already running. Conversely, withkill_after_run=False, Altium stays open with the project loaded (and closing it manually afterward may prompt to save modified documents afterDM_Compile).- Strictly sequential execution:
run_many()runs requests one at a time and reuses the samerun_outjob.pas/run_outjob.PrjScrfilenames inside the runner's script directory; do not invoke multiple runners concurrently on the same machine. Passstage_outjob_copy=FalseonOutJobRunRequestwhen running registered project.OutJobfiles inside a disposable copy. - Slow failure on bad launch: If
X2.EXEexits with a non-zero launch code before writing the sentinel file, the runner still polls untiltimeout_secondselapses rather than failing immediately.
Related Pages
- Fab & FabView — cross-platform, Altium-free Gerber, NC drill, IPC-2581B, PCB SVG, PnP, and PCB BOM generation
- PrjPcb Guide — project containers, variants, and OutJob discovery