Library Classes
Dynamic Library Factory
pyAltiumLib is a reader and renderer for Altium Library files implemented in Python.
- pyaltiumlib.read(filepath: str, libfile_obj=None) SchLib | PcbLib
Reads an Altium library file and returns the corresponding library object.
This method determines whether the given file is a schematic library (.SchLib) or a PCB library (.PcbLib) and returns the appropriate class instance.
- Parameters:
filepath (str) – The path to the Altium library file.
libfile_obj (BytesIO) – An optional binary stream (BytesIO) of the Altium library file. Used when the file is read from memory instead of disk.
- Returns:
An instance of either
SchLiborPcbLib, depending on the file type.- Return type:
pyaltiumlib.schlib.lib.SchLiborpyaltiumlib.pcblib.lib.PcbLib- Raises:
FileNotFoundError – If the specified file does not exist.
ValueError – If the file type is not recognized as .SchLib or .PcbLib.
Generic Library File (Base)
- class pyaltiumlib.base.GenericLibFile(filepath: str, oleobj)
Base class for handling Altium Designer library files.
This class provides fundamental functionality for reading library files in Altium Designer format.
- Parameters:
oleobj (io.BytesIO) – A file-like object containing the altium library file binary stream
- Raises:
FileNotFoundError – If file is not a supported file.
- ComponentCount
int with total number of components in the library.
- FileName
string that contains the name of the library.
- FilePath
string that contains the file path to the library.
- LibHeader
string that stores the header information of the library.
- LibType
string that specifies the type of the library.
- Parts
List[any] is a collection of components derived from
pyaltiumlib.libcomponent.LibComponentin their specific class contained in the library.
- __repr__() str
Converts public attributes of the high level file to a string.
- Returns:
A string representation of the content of the object
- Return type:
str
- get_part(name: str) Any | None
Get a part of the library by its name.
- Parameters:
name (string) – The name of the part.
- Returns:
The part class derived from
pyaltiumlib.libcomponent.LibComponentif found, otherwise None.- Return type:
Optional[Any]
- list_parts() List[str]
List the names of all parts in the library.
- Returns:
A list of part names
- Return type:
List[str]
- read_meta() Dict
Converts public attributes of the high level file to a dictionary.
- Returns:
A dict representation of the content of the object
- Return type:
Dict
Schematic Library File (SchLib)
- class pyaltiumlib.schlib.lib.SchLib(filepath, oleobj)
Bases:
GenericLibFileSchematic class for handling Altium Designer schematic library files. During initialization the library file will be read.
- Parameters:
filepath (string) – The path to the .SchLib library file
oleobj (io.BytesIO) – A file-like object containing the altium library file binary stream
- Raises:
FileNotFoundError – If file is not a supported file.
ValueError – If library data or header can not be read
PCB Library File (PCBLib)
- class pyaltiumlib.pcblib.lib.PcbLib(filepath, oleobj)
Bases:
GenericLibFilePCB class for handling Altium Designer PCB library files. During initialization the library file will be read.
- Parameters:
filepath (string) – The path to the .PcbLib library file
oleobj (io.BytesIO) – A file-like object containing the altium library file binary stream
- Raises:
FileNotFoundError – If file is not a supported file.
ValueError – If library data or header can not be read
- Layers
Collection with default PCB Layer Definition