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

PrjPcb

AltiumPrjPcb (altium_monkey.altium_prjpcb) is the public container for Altium .PrjPcb project files. Use it to inspect or update project documents, parameters, variants, netlist/hierarchy settings, class-generation policies, and associated OutJobs.

Use it when you need to:

  1. read or update schematic, PCB, library, device-sheet, and OutJob document references (get_schdoc_paths, get_reachable_schdoc_paths, get_pcbdoc_paths, get_outjob_paths)
  2. get, set, or delete project parameters ([ParameterN]) cleanly without affecting variant parameters ([ParameterV_N])
  3. inspect parsed variants, strict admitted variation rows (admitted_variations, admitted_DNP), and variant-level [ParameterV_N] parameters
  4. inspect net_identifier_scope, netlist_options, and project/document [PrjClassGen] ECO class-generation policies
  5. create a minimal .PrjPcb via AltiumPrjPcb.create_minimal(...) or AltiumPrjPcbBuilder
  6. resolve and run a project-associated OutJob via prj.outjob().run(...)

Import note: AltiumPrjPcb, AltiumPrjPcbOutJob, AltiumPrjPcbClassGenerationOptions, and AltiumPrjPcbDocumentClassGenerationOptions are imported from altium_monkey.altium_prjpcb (AltiumPrjPcb("project.PrjPcb"); there is no .from_file(...) classmethod). AltiumPrjPcbBuilder is exported at top level from altium_monkey.

Project Parameters

Project parameters belong in the .PrjPcb (as [ParameterN] sections), not in schematic documents. Title blocks, dynamic templates, and PCB special strings resolve expressions such as =PROJECT_TITLE, =PCB_PART_NUMBER, or =VariantName from these entries.

python
from altium_monkey.altium_prjpcb import AltiumPrjPcb

prj = AltiumPrjPcb("project.PrjPcb")
prj.set_parameter("PROJECT_TITLE", "Example Project")
prj.set_parameters({"PCB_PART_NUMBER": "WN-001", "PCB_CODENAME": "demo"})
value = prj.get_parameter("PROJECT_TITLE")
prj.delete_parameter("OLD_PARAMETER")
prj.save("project.PrjPcb")

Parameter rules (matching Altium Designer):

Variants

AltiumPrjPcb.variants parses [ProjectVariantN] sections (disambiguating duplicate Description names with _1, _2, …) and exposes both the raw records and strictly admitted rows:

python
from altium_monkey.altium_prjpcb import AltiumPrjPcb

prj = AltiumPrjPcb("project.PrjPcb")
for name, info in prj.variants.items():
    print(
        name,
        "admitted DNP:", info["admitted_DNP"],
        "variant params:", info["parameters"],
    )

Each variant dictionary includes:

AltiumDesign, AltiumCompilation, and Fab consume admitted_variations: PCB-backed BOM and Pick & Place match component Not-Fitted status by UniqueId (while Pick & Place applies parameter variations by designator and PCB BOM applies them by UniqueId). Alternate fitted component rows remain in raw metadata and are not applied as schematic symbol replacements.

To create or select an empty variant header on a project:

python
prj.add_variant("A", current=True)
assert prj.get_current_variant() == "A"

add_variant(...) creates or updates an empty project variant header; it does not author component-level variation rows.

Documents, Reachability & Builders

Net Identifier Scope, Netlist Options & Class Generation

python
from altium_monkey.altium_prjpcb import (
    AltiumPrjPcb,
    AltiumPrjPcbClassGenerationOptions,
)

prj = AltiumPrjPcb("project.PrjPcb")
options = prj.class_generation_options

prj.set_class_generation_options(
    AltiumPrjPcbClassGenerationOptions(
        net_class_manual_enabled=True,
    )
)
prj.save("project.PrjPcb")

Per-document class-generation policy is available through get_document_class_generation_options(...) and set_document_class_generation_options(...) (accepting a zero-based index, project-relative path, or filename).

OutJobs

Resolve a project-associated .OutJob with prj.outjob(name=None) (defaulting to reference_gen.OutJob or the sole sibling .OutJob) or the dynamic <stem>_outjob attribute (such as prj.reference_gen_outjob), and invoke .run(...) (preferred_version defaults to None, using ALTIUM_PREFERRED_VERSION or the newest installed Altium Designer):

python
from altium_monkey.altium_prjpcb import AltiumPrjPcb

prj = AltiumPrjPcb("working-copy/project.PrjPcb")
result = prj.outjob().run(
    timeout_seconds=300,
    stage_outjob_copy=False,
)

For cross-platform Gerber, NC drill, IPC-2581B, Pick & Place, BOM, and SVG generation without desktop Altium, use board.fab() (Fab & FabView). For desktop X2.EXE OutJob automation rules — including why PDF/Publish and printer containers are not reliably supported — see Launcher & OutJobs and its Known Limitations.

Guarantees & Stability Boundaries

Examples

Start with:

  1. prjpcb_variants_and_class_generation
  2. prjpcb_make_project
  3. outjob_runner
  4. schdoc_apply_dynamic_template
  5. hello_altium_design

See AltiumDesign & Compiled Design for project-level compilation and JSON contracts.

altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)