
# IPCB_LayerIterator interface

An iterator over layers, which can be restricted to a subset of layers with its `AddFilter_` methods.

```csharp
public interface IPCB_LayerIterator
```

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

**Derived:** [IPCB_LayerListIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerListIterator.md), [IPCB_LayerObjectIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObjectIterator.md), [IPCB_LayerObjectIterator_LayerUsage](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObjectIterator_LayerUsage.md)

## Remarks

Board and layer stack methods such as [`IPCB_Board.LayerIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#layeriterator), [`IPCB_Board.MechanicalLayerIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#mechanicallayeriterator) and [`IPCB_LayerStackBase.Iterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#iterator) return the derived [`IPCB_LayerObjectIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObjectIterator.md), which also gives the layer object at each position. [`IPCB_Pad.DefinitionLayerIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Pad.md#definitionlayeriterator) returns an `IPCB_LayerIterator`.

Filters combine: each `AddFilter_` call keeps only the layers that also pass the filters added before it, so for example signal layers combined with mechanical layers leave no layers to visit. Every `AddFilter_` method returns this iterator, so calls can be chained.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddFilter_ElectricalLayers](#addfilter_electricallayers) | [IPCB_LayerIterator](#) | Restricts the iteration to electrical layers (signal and internal plane layers) and returns this iterator. |
| [AddFilter_InternalPlaneLayers](#addfilter_internalplanelayers) | [IPCB_LayerIterator](#) | Restricts the iteration to internal plane layers and returns this iterator. |
| [AddFilter_LayerSet](#addfilter_layerset) | [IPCB_LayerIterator](#) | Restricts the iteration to the layers of a layer set and returns this iterator. |
| [AddFilter_LayerSet_1](#addfilter_layerset_1) | [IPCB_LayerIterator](#) | Restricts the iteration to the layers of a set of layer values and returns this iterator. |
| [AddFilter_MechanicalLayers](#addfilter_mechanicallayers) | [IPCB_LayerIterator](#) | Restricts the iteration to mechanical layers and returns this iterator. |
| [AddFilter_MiscLayers](#addfilter_misclayers) | [IPCB_LayerIterator](#) | Restricts the iteration to the layers that are not signal, internal plane, mechanical or dielectric layers, such as the overlay, solder mask, paste mask, keep-out and multi-layer layers, and returns… |
| [AddFilter_SignalLayers](#addfilter_signallayers) | [IPCB_LayerIterator](#) | Restricts the iteration to signal layers and returns this iterator. |
| [First](#first) | `bool` | Moves to the first layer that passes the filters; returns `false` when there is none. |
| [Layer](#layer) | [V7_LayerBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/V7_LayerBase.md) | Returns the layer at the iterator's current position. |
| [Next](#next) | `bool` | Moves to the next layer that passes the filters; returns `false` when there are no more layers. |
| [SetBeforeFirst](#setbeforefirst) | `void` | Resets the iterator to the position before the first layer. |

### AddFilter_ElectricalLayers

Restricts the iteration to electrical layers (signal and internal plane layers) and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_ElectricalLayers();
```

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

### AddFilter_InternalPlaneLayers

Restricts the iteration to internal plane layers and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_InternalPlaneLayers();
```

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

### AddFilter_LayerSet

Restricts the iteration to the layers of a layer set and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_LayerSet(IPCB_LayerSet argLayerSet);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argLayerSet` | [IPCB_LayerSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerSet.md) | value |

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

### AddFilter_LayerSet_1

Restricts the iteration to the layers of a set of layer values and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_LayerSet_1(TLayerPartitionSet argLayerSet);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argLayerSet` | [TLayerPartitionSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TLayerPartitionSet.md) | value |

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

Gives the same result as [`AddFilter_LayerSet`](#addfilter_layerset) with an [`IPCB_LayerSet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerSet.md) that contains the same layers.

### AddFilter_MechanicalLayers

Restricts the iteration to mechanical layers and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_MechanicalLayers();
```

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

### AddFilter_MiscLayers

Restricts the iteration to the layers that are not signal, internal plane, mechanical or dielectric layers, such as the overlay, solder mask, paste mask, keep-out and multi-layer layers, and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_MiscLayers();
```

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

### AddFilter_SignalLayers

Restricts the iteration to signal layers and returns this iterator.

```csharp
IPCB_LayerIterator AddFilter_SignalLayers();
```

**Returns:** [IPCB_LayerIterator](#)

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

### First

Moves to the first layer that passes the filters; returns `false` when there is none.

```csharp
bool First();
```

**Returns:** `bool`

Equivalent to [`SetBeforeFirst`](#setbeforefirst) followed by `Next`, so a loop can start with `First` and call `Next` at the end of each pass.

### Layer

Returns the layer at the iterator's current position.

```csharp
V7_LayerBase Layer();
```

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

Extension method of `IPCB_LayerIteratorHelper` (`using PCB;`).

The position is set by `First` and `Next`; read `Layer` only after one of them returned `true`.

### Next

Moves to the next layer that passes the filters; returns `false` when there are no more layers.

```csharp
bool Next();
```

**Returns:** `bool`

After [`SetBeforeFirst`](#setbeforefirst), or when the iterator is new, `Next` moves to the first layer.

**Examples:** [Extension_InternalPlaneLayer](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_InternalPlaneLayer/Source%20Code/Commands.cs#L35)

### SetBeforeFirst

Resets the iterator to the position before the first layer.

```csharp
void SetBeforeFirst();
```

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

Call `Next` to move to the first layer.

**Examples:** [Extension_InternalPlaneLayer](https://github.com/AltiumDeveloper/ad-sdk-examples/blob/5b144f54740a53ec578b3b6c3f902b831e0b1144/Extension_InternalPlaneLayer/Source%20Code/Commands.cs#L34)

## Returned by

[IPCB_LayerSet.LayerIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerSet.md#layeriterator), [IPCB_Pad.DefinitionLayerIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Pad.md#definitionlayeriterator), [IPCB_SystemOptions.LayerColorIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_SystemOptions.md#layercoloriterator), [IPCB_Via.DefinitionLayerIterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Via.md#definitionlayeriterator)

## Accepted by

[IPCB_LayerSetUtils.Factory_3](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerSetUtils.md#factory_3)
