On This Page (6)
Asset & Library Extraction
High-level inspection and extraction workflows let automation preview what is inside an Altium document or library, filter by asset kind, compute content hashes, and extract exactly one selected item — without writing temporary bulk directories or manipulating raw OLE streams.
Choosing An Extraction Surface
| Workflow | API | Sources | Output |
|---|---|---|---|
| Unified selectable inventory (symbols, footprints, models, fonts, opaque payloads) | source.asset_inventory(...) + source.extract_asset(ref) | AltiumPcbDoc, AltiumPcbLib, AltiumSchDoc, AltiumSchLib | Single-item AltiumPcbLib / AltiumSchLib or payload bytes (altium_monkey.extractable_assets.a0) |
| Focused PCB binary inventory (3D models, embedded fonts, opaque streams only) | source.embedded_asset_inventory(...) + get_embedded_*_payload(index) | AltiumPcbDoc, AltiumPcbLib | Payload bytes (altium_monkey.pcb.embedded_assets.a0) |
| Library split / merge | AltiumSchLib.split(...) / merge(...), AltiumPcbLib.split(...) | AltiumSchLib, AltiumPcbLib | Split per-entry libraries or combined library |
| Bulk extraction from documents | schdoc.extract_schlib(...) / extract_symbols(...), pcbdoc.extract_pcblib(...), schdoc.extract_embedded_images(...) | AltiumSchDoc, AltiumPcbDoc | Combined or split libraries and decoded images |
| Integrated library unpacking | AltiumIntLib.from_file(...) | .IntLib | Embedded .SchLib, .PcbLib, and model streams |
Unified Extractable Assets (asset_inventory)
Use asset_inventory(...) and extract_asset(...) when a tool needs to preview or select one item from a document or library:
inventory = source.asset_inventory(include_hashes=True)
footprint = next(
(item for item in inventory.by_kind("pcb_footprint") if item.can_extract),
None,
)
if footprint is None:
raise RuntimeError("no extractable footprint found")
extracted = source.extract_asset(footprint.ref)
extracted.pcblib.save(extracted.filename)For schematic symbols from a .SchDoc or .SchLib:
symbol = next(
(item for item in schdoc.asset_inventory().by_kind("sch_symbol") if item.can_extract),
None,
)
if symbol is None:
raise RuntimeError("no extractable schematic symbol found")
single_symbol = schdoc.extract_asset(symbol.ref)
single_symbol.schlib.save("selected_symbol.SchLib")Inventory Types & Asset Kinds
AltiumAssetInventory: source kind, source path, and asset summaries.AltiumAssetSummary: display name, extractability flags, optional payload SHA-256 hash, typeddetails, and oneAltiumAssetRef.AltiumAssetRef: source-local selection handle returned by the inventory.AltiumExtractedAsset: result for one selected asset (pcblib,schlib, orpayloadbytes plus suggestedfilename).
Supported asset kinds and typed detail models:
| Kind | Payload | Typed Details Class |
|---|---|---|
embedded_model | Decompressed 3D model bytes | EmbeddedModelAssetDetails (format, id, sizes, embedded flag, PCB references) |
embedded_font | Decompressed PcbDoc TrueType font bytes | EmbeddedFontAssetDetails (style, sizes, support status) |
opaque_embedded | Preserved raw stream bytes | OpaqueEmbeddedAssetDetails (raw size, support status, reason) |
pcb_footprint | Single-footprint AltiumPcbLib | PcbFootprintAssetDetails (pattern, occurrence, source library, components, pad/primitive counts) |
sch_symbol | Single-symbol AltiumSchLib | SchSymbolAssetDetails (display names, selected designator, library identity, pin/object/part counts) |
sch_image is reserved in the in-process vocabulary for future schematic image inventory work and is not part of the A0 JSON schema. Use asset.details for consumer logic; asset.extras is reserved for non-contract annotations and is always {} in A0 JSON.
Reference Durability & Hashes
- File-backed refs are durable through normalized
source_pathidentity. - Unsaved in-memory refs carry an opaque process-local
source_instance_idvalid only for that live instance in the current process. - Pass
include_hashes=Truewhen downstream tools need content identity:payload_sha256is emitted only for assets with direct payload bytes (embedded_model,embedded_font,opaque_embedded) when the payload is available. Footprints and symbols extract as library objects and leavepayload_sha256asNone. AltiumAssetInventory.to_dict()emitsaltium_monkey.extractable_assets.a0(extractable_assets_a0.schema.json).
Focused Embedded PCB Assets (embedded_asset_inventory)
Use AltiumPcbDoc.embedded_asset_inventory(...) or AltiumPcbLib.embedded_asset_inventory(...) when a tool only needs PCB binary payload metadata (preview, dedupe, import dry-run) without enumerating logical footprints or symbols:
inventory = pcbdoc.embedded_asset_inventory(include_hashes=True)
for model in inventory.models:
print(model.extraction_filename, model.payload_available, model.payload_sha256)
model = next((item for item in inventory.models if item.payload_available), None)
if model is None:
raise RuntimeError("no available embedded model payload found")
payload = pcbdoc.get_embedded_model_payload(model.index)Key guarantees:
- Summary APIs never write files; payload access is explicit and indexed (
get_embedded_model_payload(index)/get_embedded_font_payload(index)). payload_availablereflects actual stream accessibility. Corrupt supported payloads stay visible for review withpayload_available=False,payload_sha256=None, and no decompressed size; selecting one raises a clear decompression error.- PcbLib
Library/EmbeddedFontsstreams are reported as preservedopaque_assetsrather than typed font records; inspectsupport_statusandreasonwhen deciding how to handle them. EmbeddedAssetInventory.to_dict()emitsaltium_monkey.pcb.embedded_assets.a0(embedded_assets_a0.schema.json).