Read a PcbLib
read_pcblibRead Altium .PcbLib files to extract every footprint and its primitives plus mechanical-layer details as structured JSON in millimetres for library study or read-modify-write edits.
Instructions
Read an Altium .PcbLib file: every footprint with its description, height and primitives (pads, vias, tracks, arcs, regions, fills, text, component_bodies) as structured JSON, all coordinates and dimensions in millimetres, plus mechanical_layers: the name, kind (3DBodyTop, AssemblyTop, CourtyardTop and so on) and enabled flag the library's own layer stack gives each mechanical layer it uses, which can differ from the fixed names primitives are reported under (Mechanical 4 is Top Courtyard here, but a library may make it its 3D Body layer). Use it to study a library's footprint style or to fetch data for a read-modify-write. For one footprint whose name you know, get_component is cheaper; to find footprints by name pattern across libraries, search_components; for names alone, list_components. Each footprint is the same JSON shape get_component, export_library and write_pcblib use, so a footprint read here can be passed to write_pcblib or update_component as it is. Fields such as guid, unique_id, raw_tail, raw_block, raw_geometry, raw_contours, raw_layer_id, additional_parameters, param_key_order, primitive_order and storage_name are fidelity carriers: pass them back unchanged and the rewrite is byte-identical to the source; omit them when authoring from scratch. A list with no entries and an optional field with no value are omitted rather than empty or null. compact (default true) omits a pad's per-layer size and shape arrays when its stack_mode is Simple, since they only repeat the top-level values; set it false to see every layer. For a large library, page with limit and offset: the result reports total_count, returned_count, offset and has_more. component_name fetches one footprint and turns paging off.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Optional: maximum number of footprints to return, 1 or more (default: all) | |
| offset | No | Optional: skip the first N footprints, 0 or more (default: 0) | |
| compact | No | If true (default), omit per-layer pad data when stack_mode is Simple. Set to false for full output. | |
| filepath | Yes | Path to the .PcbLib file | |
| component_name | No | Optional: fetch only this footprint, by name in any case; a name the library does not hold is an error naming the available footprints |