
# IPCB_LibraryIterator interface

An iterator that fetches the footprints ([`IPCB_LibComponent`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LibComponent.md)) of a PCB library.

```csharp
public interface IPCB_LibraryIterator : IPCB_AbstractIterator
```

**Namespace:** PCB · **Assembly:** Altium.SDK.Interfaces

**Inherits:** [IPCB_AbstractIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md)

## Remarks

Create it with [`IPCB_Library.LibraryIterator_Create`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Library.md#libraryiterator_create) and destroy it with [`IPCB_Library.LibraryIterator_Destroy`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Library.md#libraryiterator_destroy). To fetch the child objects of a footprint, such as pads and tracks, use a group iterator ([`IPCB_Group.GroupIterator_Create`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Group.md#groupiterator_create)).

## Example

Count the primitives of every footprint in the current PCB library.

```csharp
using System.IO;
using PCB;

IPCB_Library currentLib = PCB.GlobalVars.PCBServer?.GetCurrentPCBLibrary();
if (currentLib == null)
{
    DXP.Utils.ShowInfo("This is not a PCB library document", "Footprints");
    return;
}

// Each page of the library is a footprint.
IPCB_LibraryIterator footprintIterator = currentLib.LibraryIterator_Create();
footprintIterator.SetState_FilterAll();
string s = "";
bool firstTime = true;
try
{
    // A footprint is an IPCB_LibComponent, which inherits from IPCB_Group,
    // a container object that stores primitives.
    var footprint = footprintIterator.FirstPCBObject() as IPCB_LibComponent;
    while (footprint != null)
    {
        if (firstTime)
        {
            s = s + Path.GetFileName(footprint.GetState_Board().GetState_FileName()) + "\r";
            s = s + " Current Footprint : " +
                currentLib.GetState_CurrentComponent().GetState_Pattern() + "\r" + "\r";
        }
        s = s + footprint.GetState_Pattern();

        IPCB_GroupIterator iterator = footprint.GroupIterator_Create();
        iterator.SetState_FilterAll();
        // Count the primitives of the footprint.
        // IPCB_LibComponent also has a GetPrimitiveCount method.
        int noOfPrims = 0;
        IPCB_Primitive aObject = iterator.FirstPCBObject();
        while (aObject != null)
        {
            noOfPrims++;
            // Process aObject here.
            aObject = iterator.NextPCBObject();
        }
        s = s + " has " + noOfPrims + " Primitives." + "\r";
        firstTime = false;
        footprint.GroupIterator_Destroy(ref iterator);
        footprint = footprintIterator.NextPCBObject() as IPCB_LibComponent;
    }
}
finally
{
    currentLib.LibraryIterator_Destroy(ref footprintIterator);
}
DXP.Utils.ShowInfo(s, "Footprints");
```

This interface declares no members of its own.

## Inherited members

- From [IPCB_AbstractIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md): [AddFilter_AllLayers](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_alllayers), [AddFilter_Area](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_area), [AddFilter_IPCB_LayerSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_ipcb_layerset), [AddFilter_LayerSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_layerset), [AddFilter_LayerSet_1](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_layerset_1), [AddFilter_LayerSet_2](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_layerset_2), [AddFilter_ObjectSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_objectset), [FirstPCBObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#firstpcbobject), [NextPCBObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#nextpcbobject), [SetState_FilterAll](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#setstate_filterall)

## Returned by

[IPCB_Library.LibraryIterator_Create](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Library.md#libraryiterator_create)

## Accepted by

[IPCB_Library.LibraryIterator_Destroy](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Library.md#libraryiterator_destroy)

## Examples

Used in the SDK examples: [Extension_PcbLibComponentToSTEP](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibComponentToSTEP/Source%20Code/Commands.cs#L37), [Extension_PcbLibToImage](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PcbLibToImage/Source%20Code/Commands.cs#L43).
