IntLib
AltiumIntLib reads existing Altium integrated libraries and creates them from ordered prepared source libraries.
Create an IntLib
Prepare and validate the source libraries first, then package their exact bytes:
from altium_monkey import AltiumIntLib
result = AltiumIntLib.create_from_libraries(
"passives.IntLib",
schlib_paths=["prepared/Resistors.SchLib", "prepared/Capacitors.SchLib"],
pcblib_paths=["prepared/Metric.PcbLib", "prepared/Imperial.PcbLib"],
)
print(result.component_count, result.output_sha256)
for source in result.sources:
print(source.stream_path, source.sha256)
for warning in result.warnings:
print(warning.code, warning.subject)The method derives all cross-reference and parameter metadata. It supports shared and alternate PCBLIB footprint choices, requires exactly one current choice when a component has choices, preserves embedded PcbLib assets, and reports unused footprints as warnings. Existing destinations require overwrite=True.
Compiler-owned component fields are derived by the writer. A redundant source Comment of =Value or Description equal to the symbol description is canonicalized; conflicting reserved source parameters are rejected.
The writer requires at least one SchLib and permits a model-free build with no PcbLib. Input order controls SchLib/<n>.schlib and PCBLib/<n>.pcblib numbering. Component and footprint names must be globally unique across their respective input lists. It does not merge libraries, apply catalogs, accept caller-authored metadata streams, package a separate PCB3DLib, or support non-PCBLIB model types. It adds no arbitrary component-count or package-size caps. Creation is deterministic and cross-platform.
Read and Extract
Use the reader to:
- list component and model metadata from
LibCrossRef.Txt - find embedded
.SchLib,.PcbLib, and.PCB3DLibsource streams - extract source streams to normal files
- write a simple
.LibPkgreferencing extracted sources - split extracted SchLib/PcbLib files with their normal library APIs
Some vendor-generated libraries contain extractable source streams but malformed cross-reference metadata. AltiumIntLib still opens those files for source recovery. Check component_parse_error when metadata availability matters:
from altium_monkey import AltiumIntLib
with AltiumIntLib("vendor.IntLib") as intlib:
if intlib.component_parse_error:
print(f"Component metadata unavailable: {intlib.component_parse_error}")
intlib.extract_sources("extracted_sources")Guarantees & Stability Boundaries
- Transactional writes:
create_from_libraries(...)builds from immutable source-byte snapshots, reopens and validates the candidate package, and publishes atomically; existing outputs requireoverwrite=True. - Metadata stream envelope: The writer emits the
0x02+ zlib stream envelope; the reader decodesLibCrossRef.TxtandParameters .binwith Altium's envelope rules (0x02selects zlib; other first bytes pass raw payloads; truncated or zero-length metadata streams are refused;Version.Txtand non-metadata streams stay pass-through;decompress=Falsealways returns exact stored bytes).
Examples
Start with:
See SchLib and PcbLib for preparing or working with source libraries.