
# IPCB_MechanicalLayerPairs interface

The mechanical layer pairs of a PCB document, each pair linking two mechanical layers as counterparts on the two sides of the board.

```csharp
public interface IPCB_MechanicalLayerPairs
```

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

## Remarks

The collection is the [`IPCB_Board.MechanicalPairs`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#mechanicalpairs) property.

When a component is flipped to the other side of the board, its objects on a paired mechanical layer move to the other layer of the pair, as objects on the top and bottom copper, overlay, paste mask and solder mask layers do.

`Count` returns the number of pairs; [`LayerPair`](#layerpair) returns the pair at an index from 0 to `Count` - 1 as a [`MechanicalLayerPair`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/MechanicalLayerPair.md) with the two layers of the pair.

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [LayerPair](#layerpair) | [MechanicalLayerPair](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/MechanicalLayerPair.md) | get | The pair at the given index, as a [`MechanicalLayerPair`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/MechanicalLayerPair.md) with the two layers of the pair. |
| [LayerPairKind](#layerpairkind) | [TMechanicalLayerPairKind](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TMechanicalLayerPairKind.md) | get; set | The kind of the pair at the given index, such as assembly, courtyard or 3D body. |

### LayerPair

The pair at the given index, as a [`MechanicalLayerPair`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/MechanicalLayerPair.md) with the two layers of the pair.

```csharp
MechanicalLayerPair GetState_LayerPair(int argI);
```

**Type:** [MechanicalLayerPair](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/MechanicalLayerPair.md) · **Access:** read-only · **Index:** `argI` (`int`)

The accessors are extension methods of `IPCB_MechanicalLayerPairsHelper` (`using PCB;`).

For an index outside 0 to `Count` - 1, both layers of the returned pair are no layer.

### LayerPairKind

The kind of the pair at the given index, such as assembly, courtyard or 3D body.

```csharp
TMechanicalLayerPairKind GetState_LayerPairKind(int argI);
void SetState_LayerPairKind(int argI, TMechanicalLayerPairKind argKind);
```

**Type:** [TMechanicalLayerPairKind](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TMechanicalLayerPairKind.md) · **Access:** read/write · **Index:** `argI` (`int`)

The accessors are extension methods of `IPCB_MechanicalLayerPairsHelper` (`using PCB;`).

Reading returns the kind shared by both layers of the pair, and `TMechanicalLayerPairKind.mlpUndefined` when the two layers have different kinds or the index is out of range. Assigning a kind changes the kinds of both layers and updates their names. Unless the board uses additional rigid-flex layers, the assignment does nothing when the board already has a mechanical layer of either layer kind that the pair kind uses.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [AddPair](#addpair) | `int` | Adds a pair of two mechanical layers and returns the index of the new pair. |
| [Clear](#clear) | `void` | Removes all pairs from the collection. |
| [Count](#count) | `int` | Returns the number of mechanical layer pairs. |
| [CreatePairByKind](#createpairbykind) | `int` | Adds two new mechanical layers of the given pair kind to the board, pairs them, and returns the index of the new pair. |
| [Export_ToParameters](#export_toparameters) | `void` | Writes all pairs into a parameter string. |
| [FlipLayer](#fliplayer) | `bool` | Replaces a mechanical layer with the other layer of its pair. |
| [FlipLayerV7](#fliplayerv7) | `bool` | Replaces a mechanical layer with the other layer of its pair; returns true when the layer was replaced. |
| [Import_FromParameters](#import_fromparameters) | `void` | Replaces all pairs with the pairs read from a parameter string. |
| [LayerUsed](#layerused) | `bool` | Returns whether the given layer belongs to any pair. |
| [PairDefined](#pairdefined) | `bool` | Returns whether a pair of the two given layers exists, in either order. |
| [RemovePair](#removepair) | `bool` | Removes the pair of the two given layers, given in either order; returns true when a pair was removed. |

### AddPair

Adds a pair of two mechanical layers and returns the index of the new pair.

```csharp
int AddPair(V7_LayerBase argLayer1, V7_LayerBase argLayer2);
int AddPair(IV7_Layer argLayer1, IV7_Layer argLayer2);
```

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

**Returns:** `int`

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

Returns -1 and adds nothing when either layer is not a mechanical layer. The pair is added even when the same pair is already defined; use [`PairDefined`](#pairdefined) to check first.

### Clear

Removes all pairs from the collection.

```csharp
void Clear();
```

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

### Count

Returns the number of mechanical layer pairs.

```csharp
int Count();
```

**Returns:** `int`

### CreatePairByKind

Adds two new mechanical layers of the given pair kind to the board, pairs them, and returns the index of the new pair.

```csharp
int CreatePairByKind(TMechanicalLayerPairKind argKind);
int CreatePairByKind(int argKind);
```

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

**Returns:** `int`

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

For a kind other than `TMechanicalLayerPairKind.mlpUndefined`, returns -1 and creates nothing when the board already has a mechanical layer of either layer kind that the pair kind uses; existing layers are never paired. `TMechanicalLayerPairKind.mlpUndefined` always adds and pairs two new layers of undefined kind. Returns -1 when the two layers cannot be created; a layer that was created is then removed again.

### Export_ToParameters

Writes all pairs into a parameter string.

```csharp
void Export_ToParameters(ref string argParams);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argParams` | `string` | ref |

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

### FlipLayer

Replaces a mechanical layer with the other layer of its pair.

```csharp
bool FlipLayer(ref TV6_Layer argL);
bool FlipLayer(ref int argL);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argL` | [TV6_Layer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TV6_Layer.md) | ref |

**Returns:** `bool`

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

When the layer is not in a pair, it is left unchanged. The return value does not report whether the layer was replaced; use [`FlipLayerV7`](#fliplayerv7) for that, or compare the layer before and after the call.

### FlipLayerV7

Replaces a mechanical layer with the other layer of its pair; returns true when the layer was replaced.

```csharp
bool FlipLayerV7(ref V7_LayerBase argL);
bool FlipLayerV7(ref IV7_Layer argL);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argL` | [V7_LayerBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/V7_LayerBase.md) | ref |

**Returns:** `bool`

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

Returns false and leaves the layer unchanged when the layer is not in a pair.

### Import_FromParameters

Replaces all pairs with the pairs read from a parameter string.

```csharp
void Import_FromParameters(string argParams);
```

| Parameter | Type | Passing |
| --- | --- | --- |
| `argParams` | `string` | value |

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

The collection is cleared first.

### LayerUsed

Returns whether the given layer belongs to any pair.

```csharp
bool LayerUsed(V7_LayerBase argLayer);
bool LayerUsed(IV7_Layer argLayer);
```

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

**Returns:** `bool`

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

### PairDefined

Returns whether a pair of the two given layers exists, in either order.

```csharp
bool PairDefined(V7_LayerBase argLayer1, V7_LayerBase argLayer2);
bool PairDefined(IV7_Layer argLayer1, IV7_Layer argLayer2);
```

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

**Returns:** `bool`

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

### RemovePair

Removes the pair of the two given layers, given in either order; returns true when a pair was removed.

```csharp
bool RemovePair(V7_LayerBase argLayer1, V7_LayerBase argLayer2);
bool RemovePair(IV7_Layer argLayer1, IV7_Layer argLayer2);
```

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

**Returns:** `bool`

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

When a pair is removed, the kinds of both its layers are reset to `TMechanicalLayerKind.mlUndefined`.

## Returned by

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