
# IPCB_MechanicalLayer interface

A mechanical layer of a PCB document, a general-purpose layer for the board layout, dimensions, fabrication details or any other mechanical details the design requires.

```csharp
public interface IPCB_MechanicalLayer : IPCB_LayerObject
```

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

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

## Remarks

A board can have up to 1,024 mechanical layers.

The examples visit the mechanical layers of a board with [`IPCB_Board.MechanicalLayerIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#mechanicallayeriterator) and cast each [`IPCB_LayerObjectIterator.LayerObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObjectIterator.md#layerobject) to `IPCB_MechanicalLayer`. Mechanical layers are not in the layer stack, but [`IPCB_LayerStack.LayerObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md#layerobject) also returns the layer object of a mechanical layer.

## Example

Show whether each mechanical layer of the current board is linked, enabled and displayed in single layer mode.

```csharp
using PCB;

IPCB_Board pcbBoard = PCB.GlobalVars.PCBServer?.GetCurrentPCBBoard();
if (pcbBoard == null)
    return;
// Note that the Layer stack only stores existing copper based layers.
// But you can use the LayerObject method to fetch all layers.
IPCB_LayerStack theLayerStack = pcbBoard.GetState_LayerStack();
if (theLayerStack == null)
    return;
for (TV6_Layer layer = TV6_Layer.eV6_Mechanical1; layer <= TV6_Layer.eV6_Mechanical16; layer++)
{
    var layerObj = theLayerStack.LayerObject(layer) as IPCB_MechanicalLayer;
    if (layerObj == null)
        continue;
    DXP.Utils.ShowMessage(EDP.Utils.LayerToString(new V7_Layer(layer)) + "\r" +
        " linked " + layerObj.GetState_LinkToSheet() + "\r" +
        " enabled " + layerObj.GetState_MechLayerEnabled() + "\r" +
        " displayed in single layer mode " + layerObj.GetState_DisplayInSingleLayerMode() + "\r");
}
```

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [DisplayInSingleLayerMode](#displayinsinglelayermode) | `bool` | get; set | Whether the objects on the mechanical layer stay visible while single layer mode hides the other layers. |
| [Kind](#kind) | [TMechanicalLayerKind](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TMechanicalLayerKind.md) | get; set | The kind of the mechanical layer, the role it has on the board, such as assembly notes, dimensions or board shape. |
| [LinkToSheet](#linktosheet) | `bool` | get; set | Whether the mechanical layer is linked to the sheet of the PCB document. |
| [MechLayerEnabled](#mechlayerenabled) | `bool` | get; set | Whether the mechanical layer is enabled on the PCB document. |

### DisplayInSingleLayerMode

Whether the objects on the mechanical layer stay visible while single layer mode hides the other layers.

```csharp
bool GetState_DisplayInSingleLayerMode();
void SetState_DisplayInSingleLayerMode(bool argValue);
```

**Type:** `bool` · **Access:** read/write

Reads false, and setting it does nothing, when the layer does not belong to a board.

### Kind

The kind of the mechanical layer, the role it has on the board, such as assembly notes, dimensions or board shape.

```csharp
TMechanicalLayerKind GetState_Kind();
void SetState_Kind(TMechanicalLayerKind argValue);
```

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

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

Setting a kind does nothing when the layer already has that kind, when another mechanical layer of the board already has it, or when it is a kind of a layer pair: the kinds that end in `Top` or `Bottom`, such as `TMechanicalLayerKind.mlAssemblyTop`.

Setting `TMechanicalLayerKind.mlSheet` also sets [`LinkToSheet`](#linktosheet) to true, and changing the kind from it sets [`LinkToSheet`](#linktosheet) to false. Setting `TMechanicalLayerKind.mlRouteToolPath` makes the layer the board's [`IPCB_Board.RouteToolPathLayer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#routetoolpathlayer), and changing the kind from it sets that property to no layer.

**See also:** [IPCB_MechanicalLayerPairs.LayerPairKind](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MechanicalLayerPairs.md#layerpairkind)

### LinkToSheet

Whether the mechanical layer is linked to the sheet of the PCB document.

```csharp
bool GetState_LinkToSheet();
void SetState_LinkToSheet(bool argValue);
```

**Type:** `bool` · **Access:** read/write

Once a layer is linked to the sheet, the sheet is resized automatically to fit the objects on the linked layer when a zoom command is executed. Reads false, and setting it does nothing, when the layer does not belong to a board.

### MechLayerEnabled

Whether the mechanical layer is enabled on the PCB document.

```csharp
bool GetState_MechLayerEnabled();
void SetState_MechLayerEnabled(bool argValue);
```

**Type:** `bool` · **Access:** read/write

Setting it to false does not check whether design objects are on the layer.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [MirroredLayer](#mirroredlayer) | `bool` | Returns whether the mechanical layer belongs to a mechanical layer pair, and gives the other layer of the pair. |

### MirroredLayer

Returns whether the mechanical layer belongs to a mechanical layer pair, and gives the other layer of the pair.

```csharp
bool MirroredLayer(out V7_LayerBase argMirrorLayer, IPCB_Board argBoard);
bool MirroredLayer(out IV7_Layer argMirrorLayer, object argBoard);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argMirrorLayer` | [V7_LayerBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/V7_LayerBase.md) | out | Receives the other layer of the pair, or the layer itself when it is not in a pair. |
| `argBoard` | [IPCB_Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md) | value | The board whose [`IPCB_Board.MechanicalPairs`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#mechanicalpairs) are used; null for the board the layer belongs to. |

**Returns:** `bool`

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

## Inherited members

- From [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md): [IsInLayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#isinlayerstack), [LayerDisplayName](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#layerdisplayname), [LayerName](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#layername), [LayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#layerstack), [UsedByPrims](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#usedbyprims), [V6_LayerID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#v6_layerid), [V7_LayerID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md#v7_layerid)

## Returned by

[IPCB_MasterLayerStack2.AddMechanicalLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack2.md#addmechanicallayer), [IPCB_MasterLayerStack2.FindLayerByKind](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack2.md#findlayerbykind), [IPCB_MasterLayerStack2.GetMechanicalLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack2.md#getmechanicallayer)
