File-backed refs are durable through normalized source_path identity. Refs from unsaved/live containers carry a process-local source_instance_id and are only valid for that live container instance in the current process.
Usage (read): with AltiumOleFile("component.SchLib") as ole: for path in ole.listdir(): print(path) data = ole.openstream("FileHeader")
Usage (write/round-trip): with AltiumOleFile("input.SchLib") as ole: data = ole.openstream("Symbol/Data") # modify data... ole.modify_stream("Symbol/Data", modified_data) ole.write("output.SchLib")
Members (14)
Kind
Signature
Summary
method
close(self) -> 'None'
Close the OLE file.
method
entries(self) -> 'list[OleDirEntry]'
Return every parsed directory entry in directory (SID) order.
Features: - Version 3 format (512-byte sectors) - Altium CLSID by default - Handles mini-stream for small data (<4096 bytes) - Automatic storage creation from paths
Edit an existing stream entry (for compatibility with OleWriter API).
method
fromOleFile(self, ole: 'Any') -> 'None'
Copy all streams and storages from an existing OLE file.
method
write(self, filepath: 'str | Path') -> 'None'
Write the OLE file to disk.
class
AltiumOutJob
from altium_monkey.altium_outjob importAltiumOutJob
classAltiumOutJob()->'None'
Parser and builder for Altium .OutJob output job files.
The OutJob file has three main sections: - [OutputGroup1]: Defines mediums (where output goes) and output types (what to generate) - [PublishSettings]: PDF/publish medium configuration (paths, filenames, options) - [GeneratedFilesSettings]: Generated files medium configuration (paths)
Each output type can be independently enabled/disabled per medium.
Members (25)
Kind
Signature
Summary
method
add_bom_part_type(self, enabled_medium: 'int | None' = None, *, output_name: 'str' = 'CSV-BOM', batch_mode: 'int' = 0, view_type: 'int' = 1, general: 'str | None' = None) -> 'int'
Renders barcode text records to filled polygon contours.
Converts Code 39 / Code 128 barcode data into rectangular bar polygons, laid out as Altium lays them out. Each bar is a filled rectangle; the result is a TextPolygonResult compatible with IPC-2581 output.
Sizing modes: ByMinWidth (0): Each module = barcode_min_width. Total width varies. ByFullWidth (1): Module = barcode_full_width / modules, rounded half to even to internal units.
Margins apply only to inverted barcodes; a caption sits on the text origin with the bars above it.
Case-insensitive dictionary for Altium record field lookups.
Field lookups are case-insensitive. This class preserves that behavior: - Lookups are case-insensitive: d['Location.X'] finds 'LOCATION.X' - Original keys are preserved for iteration and serialization - First key wins: if you set 'Foo' then 'FOO', 'Foo' is kept
This enables clean parsing code: value = record.get('OwnerIndex', 0) # finds 'OwnerIndex' or 'OWNERINDEX'
Instead of the verbose fallback pattern: value = r.get('OwnerIndex', 0)
The public API should not require callers to know Altium's internal Win32 BGR integer encoding. `ColorValue` provides a small boundary type that can be created from RGB, hex, or an existing Win32 color integer.
Members (6)
Kind
Signature
Summary
classmethod
from_hex(cls, color_hex: 'str') -> 'ColorValue'
Create a color helper from a `#RRGGBB` or `RRGGBB` string.
Attributes: name: Font family name (e.g., "Bunny") style: Font style (e.g., "Regular", "Bold") filename: Reconstructed filename (e.g., "Bunny-Regular.ttf") compressed_data: Zlib-compressed TTF file data raw_data: Complete raw binary data
What a TrueType Text draws from (Rust ``EmbeddedFontChoice``; EmbeddedFontResolver.choose): the board's record of ``index`` (``record``), the installed font of the family (``installed``), Altium's substitution font, Arial, in the Text's style where Altium replaces the font for ``replacement`` (``replaced``), or Windows' default face, Arial, where Altium's cache accepts the family by a record Windows refused and no face of it is installed (``default_face``).
class
EmbeddedFontName
from altium_monkey.altium_embedded_files importEmbeddedFontName
One record of a board's embedded fonts (``EmbeddedFonts6``) as saved, with its copy as the view draws it (Rust ``EmbeddedFontRecord``).
``full_name``, ``family`` and ``style_name`` are the record's saved names; ``bold`` and ``italic`` its saved bytes; ``charset`` its saved Windows charset. ``path`` is the file the renderer draws the copy from, healed when it is a face copied out of a TrueType collection with the collection's offsets, or None when it cannot be read either way; ``collection_shift`` how many bytes earlier the healed copy's tables are read, 0 for a copy read as saved. ``from_saved`` makes one from a record's saved fields and payload, healing the copy.
The face of a board's embedded fonts a TrueType Text draws from, under a font policy, and where Altium replaces the Text's font (Rust ``EmbeddedFontResolver``). Its installed fonts are ``installed_fonts``, ``InstalledFonts.this_machine()`` when none is given; a font alias the caller registered (register_font_alias) is an installed face of its family too. The policy is each question's own (``choose``). Read-only: its answers are computed once.
Calling it gives the file of the record a Text reads (``face``), the font resolver contract (``FontPathResolver``).
Where Altium stops loading a board's embedded fonts (Rust ``EmbeddedFontsEnd``). Altium reads as many records as the section's Header counts and inflates each payload with zlib. Where the inflate fails, the section's load ends there ("The following exception occurred whilst loading section EmbeddedFonts6 / Class not registered"), and no record from it on gets an entry in Altium's font cache, so their fonts count as not embedded. On a payload cut short, ZDecompress never returns and Altium stops responding; the load is taken to end there too.
``loaded`` is how many of the board's ``embedded_fonts``, in order, Altium loads; ``record`` the record the load ends at (None for a record whose fields run past the stream and for records after the Header count); ``reason`` why; ``unread`` the later records, which Altium does not read (a record identical to an earlier one is the same font and is not repeated).
Members (1)
Kind
Signature
Summary
method
leaves_unread(self, family: 'str') -> 'bool'
Whether a Text's font ``family`` names a font the end leaves
Attributes: index: Model index (0, 1, 2, ...) name: Model filename from Models/Data properties (if available) id: Model ID/GUID from Models/Data compressed_data: Zlib-compressed model data is_embedded: True if model data is embedded model_format: Classified format from filename extension
Members (4)
Kind
Signature
Summary
method
decompress(self) -> 'bytes'
Decompress embedded model data.
property
filename -> 'str'
Get filename (from name or generated).
property
is_step -> 'bool'
True when classified as STEP by extension.
method
save_to_file(self, output_path: 'Path') -> 'None'
Save decompressed model data to file.
class
EmbeddedModelAssetDetails
from altium_monkey importEmbeddedModelAssetDetails
The file a face's glyphs are read from, and why (Rust ``FaceFile``).
``drawn_from`` is ``record`` (a registered record's copy), ``installed_file`` (the face's installed file), ``embedded_copy`` (the board's copy of an installed face, healed by ``healed_shift`` bytes where it is a collection face copy), ``stand_in`` (the bundled ``stand_in``, ``metric_compatible`` or a class stand-in) or ``none`` (no file reads). ``path`` is the file drawn and ``face_index`` its face; ``record`` the board's record read; ``variation`` the named instance drawn (16.16 Fixed axis values); ``cell``, ``weight`` and ``italic`` the Windows face's, which a stand-in is drawn at and simulated as.
class
FileVersionChange
from altium_monkey.altium_file_version_info importFileVersionChange
One format change: the release that introduced it, the warnings an older (forward) or newer (backward) Altium shows for it, and its feature GUID when it is a feature entry rather than one of the fixed table.
class
FileVersionInfo
from altium_monkey.altium_file_version_info importFileVersionInfo
Document-level font table manager for SchDoc and SchLib files.
Provides: - Font lookup by name, size, and style - Automatic font creation when needed - Portable stored font ID allocation (1-999) - Font ID translation (file ID <-> internal ID)
Works with both document types: - SchDoc: Attach to AltiumSchSheet (fonts in Sheet record) - SchLib: Create with from_font_dict() (fonts in FileHeader)
Windows font metrics and integer pixel advance placement, and the bold and italic GDI simulates for the request (Rust ``GdiFontPlacement``).
``simulated_bold`` (GDI emboldens a bold text whose face is lighter than bold, _gdi_embolden_points) and ``simulated_italic`` (GDI slants an italic text whose face it does not take as italic, _gdi_italic_shear) follow from the text's ``bold`` and ``italic`` and the drawn face's ``face_weight`` and ``face_italic``, which ``TrueTypeTextRenderer.gdi_font_placement`` records: they are derived on construction (``dataclasses.replace`` included), not constructor arguments, and a layout without the face's facts simulates neither.
class
GerberOutput
from altium_monkey.altium_outjob importGerberOutput
An installed OpenType PostScript (CFF) face (Rust ``InstalledCffFace``): its family (name ID 1, cut to 31 characters), full name, weight and italic, and ``path``, the caller's file it is in (None for a face of this machine). Altium's font check and Windows' font mapper count TrueType faces only, so it never counts as installed; it is kept so that a report can say one is installed.
class
InstalledFile
from altium_monkey.altium_installed_fonts importInstalledFile
The file an installed face is drawn from (Rust ``InstalledFile``): its path, the face's index in a collection and a variable font's named instance, its axis values by tag as OpenType 16.16 Fixed integers (``Variation``). Rust draws a face of this machine whose data is outside the font folders from memory; Python, whose renderer reads files, from a copy in a folder of this process's, removed when it exits.
The installed-font list Altium's font rule reads (Rust ``InstalledFonts``).
``standard_windows()`` is the standard Windows 11 list alone, with none of this machine's font files; ``this_machine()`` (the views' default) adds this machine's installed fonts on Windows; ``from_json(path)`` reads a recorded list in their place. ``with_font_files`` and ``with_font_folders`` add the caller's TrueType faces, which count as installed and are drawn from those files. ``kind`` names the list; the caller's files and folders are ``font_files`` and ``font_folders``.
An installed TrueType face as GDI enumerates it (Rust ``InstalledTrueTypeFace``): its family, full name in the system's language, OS/2 weight and whether GDI takes it as italic; for a listed face its cell metrics (units per em, win ascent and descent, VDMX), its stand-in family and whether the stand-in has its metrics, and a variable font's named instance; ``path`` and ``face_index`` the file of a listed or given face, where this list knows one. ``installed_file()`` is the file the face is drawn from: for a face of this machine, read from the data GDI gives for it when a Text first draws from it.
Members (1)
Kind
Signature
Summary
method
installed_file(self) -> 'InstalledFile | None'
The file this face is drawn from (Rust ``installed_file``): this
class
IPC2581Output
from altium_monkey.altium_outjob importIPC2581Output
from altium_monkey.altium_text_to_polygon importStrokeTextRenderer
classStrokeTextRenderer()
Renders Altium stroke font text to line segments.
Altium's stroke font uses simple vectorized characters defined as line segments. Each character shape is stored in a normalized coordinate space and scaled to the target height.
A TrueType font as Altium answers it and as it is drawn here (Rust ``TrueTypeFontChoice``): the entry of one font, with the fields of a board's font report entry (``altium_monkey.fab.font_report.PcbFontUse``) that do not count the board's Texts.
``family``, ``bold`` and ``italic`` are the font asked for. ``altium`` is Altium's answer (``EmbeddedFontResolver.choose`` under Altium's rule: a registered record, the installed face, Arial in the font's place, with ``replaced_reason``, or Windows' default face) and ``altium_face`` the face it draws; ``face`` is the face drawn here under ``policy`` (``record`` where it is a board's record; ``differs_from_altium`` where the policy draws another face or record than Altium's rule), each by its full name. ``face_file`` is the file its glyphs are read from and why (``FaceFile``: ``drawn_from``, ``stand_in``, ``metric_compatible``, ``healed_shift``; ``path`` and ``face_index``), and ``simulated_bold`` and ``simulated_italic`` the bold and italic GDI simulates for the request on the face drawn (``GdiFontPlacement``).
Members (11)
Kind
Signature
Summary
property
differs_from_altium -> 'bool'
Whether the policy draws another face or record than Altium's
property
drawn_from -> 'FaceFileSource'
Where the face's glyphs are read from (``FaceFile.drawn_from``).
property
face_index -> 'int'
The face's index in its file, a collection's.
property
healed_shift -> 'int'
The collection shift of a healed copy drawn, else 0.
property
metric_compatible -> 'bool'
Whether the stand-in drawn has the face's character widths.
property
path -> 'str | None'
The font file the face is read from, where it reads.
property
record -> 'int | None'
The board's record drawn, where the face is one.
property
replaced_reason -> 'AltiumFontAnswer | None'
Why Altium replaces the font with Arial, where it does.
property
simulated_bold -> 'bool'
Whether GDI emboldens the face drawn: a bold request whose face is
property
simulated_italic -> 'bool'
Whether GDI slants the face drawn: an italic request whose face it
property
stand_in -> 'str | None'
The bundled stand-in drawn, where one is.
class
TrueTypeTextRenderer
from altium_monkey.altium_text_to_polygon importTrueTypeTextRenderer
Uses FreeType for glyph outline extraction and HarfBuzz for text shaping (kerning, ligatures). Output polygons can be emitted as IPC-2581 Contour/Polygon/Cutout or SVG path elements.
A text's font is chosen by ``choose_truetype_font`` under ``font_policy`` (Altium's rule, ``"altium"``, the default, or the opt-in ``"embedded_first"`` where a board's resolver is given; any other value is an error), against ``installed_fonts``, this machine's when none is given.
A listed Windows face's cell (Rust ``WindowsCell``): its units per em, win ascent and descent, and whether it has a VDMX table.
constant
ALTIUM_CLSID
from altium_monkey importALTIUM_CLSID
ALTIUM_CLSID: str
constant
ALTIUM_CLSID_BYTES
from altium_monkey importALTIUM_CLSID_BYTES
ALTIUM_CLSID_BYTES: bytes
function
altium_expr
from altium_monkey.altium_outjob import altium_expr
defaltium_expr(*parts:'str')->'str'
Build an Altium project variable expression for path/filename fields.
In Altium OutJob files, values starting with ``=`` are evaluated as expressions at output generation time. This function combines variable names and quoted literals with ``+`` concatenation and prefixes the result with ``=``.
Bare strings are treated as project variable names. Use :func:`altium_literal` to wrap literal path segments.
Args: parts: Variable names (bare) and/or quoted literals from :func:`altium_literal`.
function
altium_literal
from altium_monkey.altium_outjob import altium_literal
defaltium_literal(text:'str')->'str'
Wrap a literal string for use in an Altium path expression.
Returns the text wrapped in single quotes, as required by Altium's expression evaluator.
Args: text: Literal text (e.g. a path separator or fixed prefix).
Returns: Single-quoted string, e.g. ``'\PCB'``.
enum
AltiumFontAnswer
from altium_monkey.altium_text_to_polygon importAltiumFontAnswer
enum AltiumFontAnswer
How Altium answers a TrueType Text's family and style (Rust ``truetype_text::AltiumFontAnswer``; EmbeddedFontResolver.choose): its font cache answers it (``EMBEDDED``), an installed TrueType face does (``INSTALLED``), or Altium's substitution font, Arial, replaces it, because no installed TrueType face of the family has the style and the family has more than one (``STYLE_NOT_INSTALLED``), because the board embeds the family only in records the cache does not take for the style and no TrueType face of it is installed (``STYLE_NOT_EMBEDDED``), or because the family is neither embedded nor installed as a TrueType face (``NOT_FOUND``).
Members (5)
Kind
Signature
Summary
member
EMBEDDED= 'embedded'
member
INSTALLED= 'installed'
member
STYLE_NOT_INSTALLED= 'style_not_installed'
member
STYLE_NOT_EMBEDDED= 'style_not_embedded'
member
NOT_FOUND= 'not_found'
function
canonicalize_stroke_font_type
from altium_monkey.altium_text_to_polygon import canonicalize_stroke_font_type
Normalize PCB TEXT stroke font ids to the canonical 1/2/3 range.
Native PCB TEXT records use: 1 -> Default 2 -> Sans Serif 3 -> Serif
Older tests and some helper callsites historically treated the field as 0-based. Keep 0/None/unknown values as a compatibility path to Default, but normalize them immediately so all downstream code sees one convention.
function
choose_truetype_font
from altium_monkey.altium_text_to_polygon import choose_truetype_font
Choose the font a TrueType text draws with, by Altium's font rule.
The installed fonts are ``installed_fonts`` (this machine's when none is given), or a board resolver's own. With a board's resolver (``EmbeddedFontResolver``), or with none, what ``EmbeddedFontResolver.choose`` chooses under ``font_policy``: Arial in the text's style, origin ``replaced``, drawn from Arial's own file, where Altium replaces the font with its substitution font (Arial itself is never replaced); else the board's record it draws; else the installed face Windows' font mapper draws; else Windows' default face, Arial. The policy is Altium's rule (``"altium"``) unless the caller opts in to ``"embedded_first"``, which draws the board's readable record of the text's style first; any other value is an error.
With another resolver, the files it gives for the family's four styles count as installed faces of the family, and Altium's rule runs on them as on any installed face (a CFF file does not count). A registered font alias (register_font_alias) is an installed face of its family too.
function
classify_embedded_model_format
from altium_monkey.altium_embedded_files import classify_embedded_model_format
Decode a ``FileVersionInfo/Data`` stream as Altium imports it: entries 0 to COUNT-1, a missing key an empty field, keys in any case, values as comma-separated UTF-16 code units. Never raises.
constant
DIR_ENTRY_SIZE
from altium_monkey importDIR_ENTRY_SIZE
DIR_ENTRY_SIZE: int
constant
ENDOFCHAIN
from altium_monkey importENDOFCHAIN
ENDOFCHAIN: int
function
face_advances_differ
from altium_monkey.altium_text_to_polygon import face_advances_differ
Whether two font files' faces have other advance widths (Rust ``face_advances_differ``): for any character both map in a cmap subtable of the same platform and encoding, the advances differ at a common em (each advance times the other face's units per em, compared as integers). False where either face cannot be read.
constant
FREESECT
from altium_monkey importFREESECT
FREESECT: int
constant
HEADER_SIZE
from altium_monkey importHEADER_SIZE
HEADER_SIZE: int
enum
LineShape
from altium_monkey importLineShape
enum LineShape
Line ending shape enumeration for polylines.
Controls the shape drawn at the start/end of polylines. These are "decorations" like arrowheads, tails, circles, squares.
Stored as the schematic line-shape enum.
Members (7)
Kind
Signature
Summary
member
NONE= 0
member
ARROW= 1
member
SOLID_ARROW= 2
member
TAIL= 3
member
SOLID_TAIL= 4
member
CIRCLE= 5
member
SQUARE= 6
enum
LineStyle
from altium_monkey importLineStyle
enum LineStyle
Line style enumeration for polylines and lines.
Members (4)
Kind
Signature
Summary
member
SOLID= 0
member
DASHED= 1
member
DOTTED= 2
member
DASH_DOT= 3
enum
LineWidth
from altium_monkey importLineWidth
enum LineWidth
Schematic line width enumeration.
Native Altium schematic size mapping: - 0 = Smallest - 1 = Small - 2 = Medium - 3 = Large
Members (4)
Kind
Signature
Summary
member
SMALLEST= 0
member
SMALL= 1
member
MEDIUM= 2
member
LARGE= 3
constant
MINI_SECTOR_SIZE
from altium_monkey importMINI_SECTOR_SIZE
MINI_SECTOR_SIZE: int
constant
MINI_STREAM_CUTOFF
from altium_monkey importMINI_STREAM_CUTOFF
MINI_STREAM_CUTOFF: int
function
normalize_outjob_generated_paths
from altium_monkey.altium_outjob_runner import normalize_outjob_generated_paths
Normalize GeneratedFiles medium paths in an OutJob.
For every `OutputMediumN_Type=GeneratedFiles`: - `PublishSettings.OutputFilePathN` is cleared. - `PublishSettings.OutputBasePathN` is normalized to a directory path. - `GeneratedFilesSettings.RelativeOutputPathN` is set from the normalized base path.
Args: outjob_path: Path to the .OutJob file. default_generated_output_path: Relative fallback path used when existing GeneratedFiles paths are absolute or empty. bind_pcbdoc_path: Optional .PcbDoc path to inject into embedded `ConfigurationN_ItemM` `DocumentPath=` tokens. normalize_generated_fields: If True, normalize GeneratedFiles output path fields; if False, keep those fields unchanged. dry_run: If True, report required changes without writing.
function
normalize_pnp_position_mode
from altium_monkey.altium_pnp_position import normalize_pnp_position_mode
Normalize a public pick-and-place position mode name.
``altium-pick-place`` matches Altium's Pick Place export by using the center of the bounding box of component-owned pad anchor points, with a component-origin fallback when no pads exist. ``component-origin`` uses the footprint placement origin directly.
Args: position_mode: Public mode name or a small compatibility alias.
Returns: Canonical public mode name.
constant
OLE_MAGIC
from altium_monkey importOLE_MAGIC
OLE_MAGIC: bytes
function
parse_component_kind
from altium_monkey.altium_component_kind import parse_component_kind
defparse_component_kind(record:'dict[str, str]')->'ComponentKind | int'
Parse component kind from the versioned record fields.
constant
PNP_POSITION_MODE_ALTIUM_PICK_PLACE
from altium_monkey.altium_pnp_position importPNP_POSITION_MODE_ALTIUM_PICK_PLACE
PNP_POSITION_MODE_ALTIUM_PICK_PLACE: str
constant
PNP_POSITION_MODE_COMPONENT_ORIGIN
from altium_monkey.altium_pnp_position importPNP_POSITION_MODE_COMPONENT_ORIGIN
PNP_POSITION_MODE_COMPONENT_ORIGIN: str
constant
PNP_POSITION_MODES
from altium_monkey.altium_pnp_position importPNP_POSITION_MODES
PNP_POSITION_MODES: tuple
function
PnpPositionMode
from altium_monkey.altium_pnp_position importPnpPositionMode
defPnpPositionMode(*args,**kwargs)
enum
ReadOnlyState
from altium_monkey importReadOnlyState
enum ReadOnlyState
Read-only state for parameters and designators.
Controls which parts of the parameter/designator can be edited: - NONE: Fully editable - NAME: Name is read-only, value editable - VALUE: Value is read-only, name editable - NAME_AND_VALUE: Both name and value are read-only
Members (4)
Kind
Signature
Summary
member
NONE= 0
member
NAME= 1
member
VALUE= 2
member
NAME_AND_VALUE= 3
function
rgb_to_win32_color
from altium_monkey.altium_record_types import rgb_to_win32_color
Map a human-readable label to the canonical stroke-font id.
Matching is case-insensitive. A label containing ``sans`` maps to Sans Serif (2), even when it also contains ``serif``; otherwise a label containing ``serif`` maps to Serif (3). All other labels map to Default (1).