
# IPCB_BoardIterator interface

An iterator that fetches the design objects of a PCB document.

```csharp
public interface IPCB_BoardIterator : IPCB_AbstractIterator
```

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

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

## Remarks

With the iterator, you can control which objects on which layers are fetched with the [`AddFilter_ObjectSet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_objectset) and [`AddFilter_LayerSet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_layerset) methods, and with [`AddFilter_Method`](#addfilter_method) whether objects that belong to a component or another group object are included. [`AddFilter_Area`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_area) does not restrict a board iterator: use an [`IPCB_SpatialIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_SpatialIterator.md) to fetch the objects in an area.

## Example

Count the pads on the current board.

```csharp
using PCB;

IPCB_Board board = PCB.GlobalVars.PCBServer?.GetCurrentPCBBoard();
if (board == null)
    return;

// Set up a board iterator for pads on all layers.
IPCB_BoardIterator iterator = board.BoardIterator_Create();
iterator.AddFilter_ObjectSet(new PCB.TObjectSet { TObjectId.ePadObject });
iterator.AddFilter_AllLayers();
iterator.AddFilter_Method(TIterationMethod.eProcessAll);

// Search for and count the pads.
int padNumber = 0;
for (IPCB_Primitive pad = iterator.FirstPCBObject(); pad != null; pad = iterator.NextPCBObject())
    padNumber++;
board.BoardIterator_Destroy(ref iterator);

DXP.Utils.ShowInfo("Pad Count = " + padNumber, "Pads");
```

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddFilter_Method](#addfilter_method) | `void` | Selects the objects to fetch by whether they belong to a group object, such as a component. |

### AddFilter_Method

Selects the objects to fetch by whether they belong to a group object, such as a component.

```csharp
void AddFilter_Method(TIterationMethod argMethod);
void AddFilter_Method(int argMethod);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argMethod` | [TIterationMethod](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TIterationMethod.md) | value | `TIterationMethod.eProcessAll` fetches all objects. `TIterationMethod.eProcessFree` fetches only free objects: objects that are not part of a component, polygon, coordinate or dimension, and group objects such as components themselves. `TIterationMethod.eProcessComponent` fetches only the objects that are not free. |

**Returns:** nothing (`void`)

The first overload is an extension method of `IPCB_BoardIteratorHelper` (`using PCB;`) with typed parameters; the second is declared by the interface.

A new iterator fetches all objects (`TIterationMethod.eProcessAll`). The setting applies to the objects fetched by the following [`FirstPCBObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#firstpcbobject) and [`NextPCBObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#nextpcbobject) calls.

**Examples:** [Extension_BOMManager](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_BOMManager/Source%20Code/PcbBom.cs#L41), [Extension_Pad_SolderMask](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_Pad_SolderMask/Source%20Code/Commands.cs#L38)

## 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_Board.BoardIterator_Create](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#boarditerator_create)

## Accepted by

[IPCB_Board.BoardIterator_Destroy](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#boarditerator_destroy)

## Examples

Used in the SDK examples: [Extension_PCBUndoRedo](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_PCBUndoRedo/Source%20Code/Commands.cs#L40), [Extension_Pad_SolderMask](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_Pad_SolderMask/Source%20Code/Commands.cs#L32).
