On This Page (9)
AltiumDesign
AltiumDesign is the project-level analysis surface. Use it when you need a compiled view across a .PrjPcb, its schematic documents, variants, component metadata, and schematic connectivity.
Use it when you need to:
- load a project from
.PrjPcb - emit the public design JSON contract
- emit the public netlist JSON contract
- inspect project netlist JSON
- generate PCB-backed pick-and-place data when a PcbDoc is referenced
- inspect project parameters, variants, components, sheets, and nets
Public Contracts
AltiumDesign.to_json(...) emits altium_monkey.design.b0.
AltiumDesign.to_netlist().to_json(...) emits altium_monkey.netlist.b0.
AltiumDesign.to_bom_payload() emits altium_monkey.schematic_bom.a0 through an immutable SchematicBomPayload. Use its to_json(), to_json_text(), or to_json_bytes() methods for a versioned transport. The established list-returning to_bom() API remains available. Its default remains a logical compiled-schematic BOM, but it now projects directly from the compiled design without constructing an intermediate netlist.
Use to_bom(use_pcb_data=True) for a faster no-compile view of physical parts placed on the board. PCB mode reads through the board's FabView (matching Altium's PcbDoc BOM): value comes from the component's comment Text (falling back to Value or Comment parameters), description uses the component's own description under the selected variant, blank-designator parts are kept, and PCB ComponentKind filtering applies. Project variant fitting and parameter variations match by component UniqueId (not designator alone) and do not mutate the footprint. It does not join or compare schematic data.
The PCB option assumes the board is synchronized. It may omit schematic-only or unplaced components, returns an empty sheet value, and can expose cached PCB parameters that differ from evaluated schematic parameters. It is available from AltiumProjectLoadMode.METADATA_ONLY.
AltiumDesign.compile(force=False) returns the lower-level compiled schematic model (AltiumCompiledDesign). Project netlist, design JSON, and physical schematic rendering derive from this compiled model. For checked C0 compilation, recursive electrical membership, and Paint IR source bindings, use AltiumCompilation and AltiumCompiledView (see C0 Compilation below).
AltiumDesign.to_physical_paint_ir(page_occurrence_ref) and AltiumDesign.to_physical_svg(page_occurrence_ref) render one compiled physical schematic page. Use these APIs for repeated sheets and multi-channel projects where one logical .SchDoc appears multiple times with different resolved designators such as R1.1, R1.2, R1A, or R1B.
AltiumDesign.to_pnp(...) returns pick-and-place entries from the project PcbDoc's FabView. The board is the default manufacturing authority: panel embedded board copies are expanded under their child board designators, component-owned Texts6 records supply physical designators and display-value comments, and exclude_no_bom=True uses the PCB component kind. Project variant Not-Fitted filtering matches by component UniqueId and parameter overrides apply by designator. Rotations format to 0.001 degrees and positions derive from whole nanometres.
The default does not compile or join the schematic. If logical metadata is explicitly required, pass use_schematic_metadata=True; matching components then use compiled schematic value, description, parameters, and component kind while placement remains PCB-owned. This option retains the earlier PnP metadata behavior and cost. The default assumes the board has been synchronized before manufacturing output.
With its default include_pnp=True, AltiumDesign.to_json(...) also includes PnP data under the optional root pnp field when a PcbDoc is referenced.
The default PnP coordinate mode is altium-pick-place. It matches Altium's Pick Place export by taking the center of the bounding box of component-owned pad anchor points and falling back to the component origin when a component has no owned pads. Use position_mode="component-origin" when the footprint placement origin is the desired coordinate. In design JSON, pnp.position_mode records the selected mode and center_x/center_y are the selected PnP position, not a generic geometric centroid.
The schema field is the contract version. These payloads do not use a root version field.
The root generator field is altium_monkey.
Standalone Netlist b0 uses structured source_pages and stable component identities. Design b0 owns a separate embedded-net compatibility projection; its root nets retain filename-only source_sheets and must not be interpreted as standalone Netlist b0 rows.
Use SchematicContractLimits to lower JSON resource ceilings (all count and byte ceilings default to uncapped 2^63 - 1, matching Altium, while max_recursion_depth stays 128 for stack safety). SchematicContractError provides a stable error code and JSON Pointer path for invalid Netlist b0, schematic-BOM a0, or C0 compilation payloads.
C0 Compilation And Compiled View
Alongside AltiumDesign.to_json() (altium_monkey.design.b0), altium-monkey provides the checked C0 compilation surface for strict electrical, source-field, and Paint IR binding workflows:
from altium_monkey import AltiumCompilation
compilation = AltiumCompilation.from_file("board.PrjPcb")
view = compilation.compiled_view
graph = view.structural_graph() # altium_monkey.structural_graph.c0
payload_bytes = compilation.to_json() # altium_monkey.compilation.c0
reloaded = AltiumCompilation.from_json(payload_bytes)Key C0 contracts and types:
AltiumCompilation(altium_monkey.compilation.c0): immutable checked compilation from.PrjPcbor.SchDoc(from_file,from_json,to_json,to_dto). Exposescompiled_view,effective_component(...), realized-page source queries (select_source,realized_sources_for_net), retained source inspection (schematic_source_json,schematic_text_records), and live Paint IR bindings viaschematic_graphics(realized_page_ref)/schematic_graphics_with_options(...).AltiumCompiledView(altium_monkey.compiled_view.c0): detached electrical and source relationship view embeddingaltium_monkey.compiled_schematic_graph.b0(pages, authoredfields, exactsource_bindings,naming_gaps,issues). Providesstructural_graph(),select_source(...),explain_net(...),sources_for_net(...), andimpacts_for_field(...).AltiumStructuralGraph(altium_monkey.structural_graph.c0): recursive electrical membership (definitions,instances,terminals,nets) plus explicitnet_bridges(Altium Net Ties of kinds 3 and 4) and transitivebridged_groupswithout merging bridged nets.- Paint IR Bindings (
altium_monkey.paint_bindings.c0): produced bycompilation.schematic_graphics(page_id)(PreparedSchematicGraphics), linking every Paint IR groupoccurrence_id(checked bypaint_sha256) to exact compiled source keys and nets viaselect_occurrence(...)andoccurrences_for_net(...).
Use AltiumCompilation / AltiumCompiledView (compilation.c0) for all new consumers — it provides strict recursive electrical membership (structural_graph.c0), Net Tie bridges, authored field-impact tracing (compiled_schematic_graph.b0, a narrower source-incidence sub-schema rather than a drop-in v2 of a0), and Paint IR occurrence-to-net bindings (paint_bindings.c0).
Removal Warning (
2026.12.25/ "santy claws"):AltiumDesign.to_json()(altium_monkey.design.b0) andAltiumCompiledSchematicGraph(altium_monkey.compiled_schematic_graph.a0) remain schema-stable in2026.11.26as a compatibility surface and will be removed in the next release (targeting2026.12.25, codename "santy claws"). Migrate consumers toAltiumCompilation.from_file()(compilation.c0).
Comparing Design b0 vs. Compilation C0
| Concern | Design b0 (AltiumDesign.to_json()) | Compilation C0 (AltiumCompilation) |
|---|---|---|
| Root contract | altium_monkey.design.b0 | altium_monkey.compilation.c0 |
| Electrical graph | Embedded compiled_schematic_graph.a0 + flat nets | structural_graph.c0 (definitions, instances, terminals, nets, net_bridges, bridged_groups) |
| Schematic graph | compiled_schematic_graph.a0 (10 collections + graphical_artifact_links) | compiled_schematic_graph.b0 inside compiled_view.c0 (pages, fields, source_bindings, naming_gaps, issues) |
| Drawing linkage | (page_occurrence_ref, "sch.dwg_scene", element_id) | paint_bindings.c0 keyed by Paint IR group occurrence_id + paint_sha256 |
| Queries | Dict traversal over JSON payload | Checked query methods (select_source, explain_net, sources_for_net, realized_sources_for_net, impacts_for_field, select_occurrence, occurrences_for_net) |
| Legacy UID-less objects | Partial or unadmitted in older projects | Keyed deterministically by file slot (slot:<stream>:<index>) alongside persisted UIDs |
Migrating From Design a2 & Raw Compiler Diagnostics
- Design a2 to Design b0: Design b0 replaces the duplicated Design a2
physical_pagesprojection with the requiredcompiled_schematic_graph(a0) and narrowphysical_page_metadata. Archived schemas (altium_monkey.design.a2,altium_monkey.design.a1) remain bundled for stored payloads but are not emitted by the current API. - Raw compiler diagnostics:
AltiumDesign.compile()returns the lower-levelAltiumCompiledDesignmodel (to_dict()). Use it for Altium-specific compiler investigation; useAltiumCompilation(C0) or Design b0's embedded graph for application and visualization workflows. - BOM & PnP authority:
to_bom()compiles schematic occurrences by default (use_pcb_data=Truereads placed PCB parts throughFabViewwithout compiling schematics).to_pnp()reads placed PCB parts throughFabViewby default (use_schematic_metadata=Truejoins schematic metadata by physical designator).
See JSON Schemas & TypeSpec for field-level contract definitions and SchematicContractLimits resource-ceiling rules.
Project Load Modes
AltiumDesign.from_prjpcb(...) accepts an AltiumProjectLoadMode:
from altium_monkey import AltiumDesign, AltiumProjectLoadMode
design = AltiumDesign.from_prjpcb(
"board.PrjPcb",
load_mode=AltiumProjectLoadMode.METADATA_ONLY,
)FULL, the default, loads the project and compile-participating SchDocs. It provides the compiler, netlist, Design JSON, BOM, schematic rendering, and schematic query APIs. Despite its name, it does not eagerly load a referenced PcbDoc: both project modes leave design.pcbdoc as None until an explicit PCB-dependent operation requests the board.
Design JSON is a mixed schematic/PCB transport for compatibility. Its include_pnp=True default loads a referenced PcbDoc to populate the optional pnp field. Use design.to_json(include_pnp=False) for schematic-only Design JSON; that path does not parse the board.
METADATA_ONLY reads neither SchDoc nor PcbDoc document bytes. It retains project metadata, compile options, project parameters, variants, DNP and component-override rows, and board discovery through get_pcbdoc_paths(). Its schdocs list and schematic-derived sheet_parameters are empty. load_pcbdoc(...) remains available and parses only the selected board. The default to_pnp() is also available in this mode and lazily loads the board; to_pnp(use_schematic_metadata=True) requires FULL because it compiles the schematic.
Schematic-dependent methods on a metadata-only design raise AltiumProjectCapabilityError; they do not return an empty result that could be mistaken for an empty design. A design does not upgrade its load mode in place. Construct a new FULL design when schematic capabilities are needed.
Loaded PcbDocs are cached by resolved source path. Equivalent filename, relative-path, and absolute-path selectors return the same mutable object, so intentional in-memory edits remain visible. Construct a new design when fresh disk state is required.
Compiled vs Logical Views
Use AltiumDesign when a consumer needs the resolved physical project view. For project inputs, these public surfaces derive from the compiled schematic model:
AltiumDesign.to_json(...)AltiumDesign.to_netlist()AltiumDesign.to_physical_paint_ir(page_occurrence_ref)AltiumDesign.to_physical_svg(page_occurrence_ref)
This means repeated sheets, channel instances, annotation-driven designator changes, and project net naming are resolved before data is emitted.
Use AltiumSchDoc.to_paint_ir() or AltiumSchDoc.to_svg() when you intentionally want the raw logical source sheet without project compile context. Those single-sheet renderers do not know which physical page instance they represent, so they do not substitute channel-resolved designators.
For projects without repeated physical sheet instances, the compiled project view decays to the familiar one-source-sheet/one-page-occurrence shape. The same graph contract still applies, so consumers do not need a separate simple project code path.
Compiled Schematic Graph
Design b0 requires compiled_schematic_graph, a variant-neutral transport with the same source-neutral ten collections used by the governed generic graph:
unit_definitionspage_definitionsunit_occurrencespage_occurrenceshierarchy_occurrencescomponent_occurrenceslocal_net_occurrencesterminal_occurrenceshierarchy_terminal_bindingsgraphical_artifact_links
Definitions describe reusable logical source material. Occurrences describe the realized compiled design, so repeated sheets and channels have distinct canonical identities. Local nets belong to page occurrences, and explicit hierarchy terminal bindings connect parent sheet entries to child ports.
The embedded graph schema is altium_monkey.compiled_schematic_graph.a0; its identity namespace is sch.compiled_schematic_graph.a0.
compile and diagnostics are optional root fields. Request them with AltiumDesign.to_json(include_compile_metadata=True) when a consumer needs compile health, resolved options, annotation state, statistics, or warning/error records. The default payload omits them to keep the normal design JSON compact.
The review-safe drawing selector is:
page_occurrence_ref + artifact_key + element_idCurrent schematic SVG and IR use artifact_key == "sch.dwg_scene". graphical_artifact_links maps each scoped selector to a component, terminal, local net, hierarchy occurrence, or page target. A bare SVG element id is not a realized identity.
physical_page_metadata is the only Altium-specific page projection retained at the Design root. Each row is keyed by canonical page_occurrence_ref and contains only presentation facts:
- physical instance path;
- channel index, prefix, and alpha token;
- logical and physical room names;
- document number.
It does not repeat components or nets. Optional Design indexes retain only non-page compatibility lookups such as component-to-net and unambiguous SVG component maps; the Design a2 page-derived indexes are retired.
Net records may include aliases and name_sources. aliases are alternate net names discovered while merging compiled connectivity. name_sources records explain where candidate names came from, including the winning compiled name, explicit labels, ports, sheet entries, power ports, and other compiled name contributors when available.
The net name is the compiled winner. aliases are useful when a schematic wire has multiple labels, when a port/sheet-entry name differs from a local net label, or when different pages contribute different candidate names to the same compiled net. Note that aliases are scoped per-net contributor names, not globally unique net keys — distinct compiled nets on different sheets or in different harness/channel instances legitimately share the same alias token (such as a local port name IN or harness member name SDA). Consumers should display or key nets by uid (or compiled name), using aliases only for provenance or non-unique search.
For multi-part components (such as a quad op-amp split across U1A..U1D), compiled physical component rows collapse all parts into one physical component entry whose classification.pin_count reflects the total physical package pin count across all parts rather than a single sub-part's pins.
Current Boundaries
Variant processing includes DNP/not-fitted handling, project current-variant state, variant metadata in design JSON, and per-designator parameter overrides. to_bom(variant=...) applies parameter overrides to component parameters, values, and descriptions while retaining DNP rows with a dnp flag. With use_pcb_data=True, the base facts come from placed PCB components and the cached PCB parameter stream rather than compiled logical components. to_pnp(variant=...) omits DNP placements for the selected variant. Design JSON component rows expose active-variant dnp and fitted state when available. Schematic SVG/IR rendering does not hide, dim, or mutate DNP component geometry by itself; consumers can apply their own policy from the metadata.
Alternate fitted component rows are preserved in project variant metadata but are not applied as semantic component replacements in BOM, netlist, PNP, or SVG output yet.
The compiled design path resolves hierarchical sheets, repeated channels, physical page instances, and annotation-file driven designator mapping for the supported project shapes. .Annotation files are parsed for compile-relevant physical designator and sheet/document metadata. Annotation NetNameManager records are preserved as annotation metadata, but are not applied as compiled flat-net renames because reference compile evidence does not apply those records during schematic compilation.
Use schematic SVG rendering directly when you only need page-level drawings. Use AltiumDesign when you need project context such as parameters, variants, the compiled schematic graph, resolved designators, or netlist data.
Use AltiumDesign.to_json(...), AltiumDesign.compile().to_dict(), or AltiumDesign.to_netlist().to_json(...) for programmatic consumers.
Use design.to_bom(use_pcb_data=True) when a PCB-backed BOM should reflect the components that are actually placed on the board. The pcbdoc_bom example shows how to build a richer custom PCB component and grouped-BOM projection.
Examples
Start with:
hello_altium_designcompiled_design_c0_and_paint_bindingspcbdoc_bompcbdoc_pick_n_placeschdoc_svgpcbdoc_statsprjpcb_make_project
hello_altium_design is the canonical project-design example for this release. It writes full Design b0 JSON, a compiled-graph summary, compiled net-name examples, and project-aware physical schematic SVGs.