
# IPCB_SpatialIterator interface

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

```csharp
public interface IPCB_SpatialIterator : IPCB_AbstractIterator
```

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

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

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

## Remarks

Create it with [`IPCB_Board.SpatialIterator_Create`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#spatialiterator_create) and destroy it with [`IPCB_Board.SpatialIterator_Destroy`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#spatialiterator_destroy). Set the object kinds, the layers and the area with the [`AddFilter_ObjectSet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_objectset), [`AddFilter_LayerSet`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_layerset) and [`AddFilter_Area`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_area) methods inherited from [`IPCB_AbstractIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md); without [`AddFilter_Area`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_AbstractIterator.md#addfilter_area) the iterator searches the whole board.

A spatial iterator skips group objects: components, polygons, split planes, nets, dimensions and coordinates are not fetched, even when the object filter includes them. Use an [`IPCB_BoardIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_BoardIterator.md) to fetch them.

## Example

Select the tracks and arcs on the top and bottom layers within an area.

```csharp
using PCB;

IPCB_Board board = PCB.GlobalVars.PCBServer?.GetCurrentPCBBoard();
if (board == null)
    return;
// Sample values: the area to search.
int x1 = EDP.Utils.MilsToCoord(1000);
int y1 = EDP.Utils.MilsToCoord(1000);
int x2 = EDP.Utils.MilsToCoord(3000);
int y2 = EDP.Utils.MilsToCoord(3000);

// Top/bottom layers and arc/track objects define
// the spatial iterator constraints.
var aSetOfLayers = new TV6_LayerSet { TV6_Layer.eV6_TopLayer, TV6_Layer.eV6_BottomLayer };
var aSetOfObjects = new PCB.TObjectSet { TObjectId.eArcObject, TObjectId.eTrackObject };
IPCB_SpatialIterator iterator = board.SpatialIterator_Create();
iterator.AddFilter_ObjectSet(aSetOfObjects);
iterator.AddFilter_LayerSet(aSetOfLayers);
iterator.AddFilter_Area(x1, y1, x2, y2);

// Iterate over tracks and arcs on the top and bottom layers.
IPCB_Primitive pcbObject = iterator.FirstPCBObject();
while (pcbObject != null)
{
    pcbObject.SetState_Selected(true);
    pcbObject = iterator.NextPCBObject();
}
board.SpatialIterator_Destroy(ref iterator);
```

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddFilter_ProcessSpecialLayers](#addfilter_processspeciallayers) | `void` | Also fetches the shapes that objects produce on the mechanical layers used as solder mask or paste mask layers of a layer stack. |

### AddFilter_ProcessSpecialLayers

Also fetches the shapes that objects produce on the mechanical layers used as solder mask or paste mask layers of a layer stack.

```csharp
void AddFilter_ProcessSpecialLayers();
```

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

The shapes are fetched after all other objects. They are new objects on the mechanical layer, created by the iterator from the objects of the requested kinds on the top or bottom layer of the layer stack and on the multi-layer; they are not objects of the board, and they are freed when the iterator is destroyed. No shapes are fetched when the object filter includes none of arcs, pads, vias, regions and fills, or when the layer filter does not include the mechanical layer.

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

## Accepted by

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