
# IPCB_MasterLayerStack interface

The master layer stack of a board, which holds the board's layers and its substacks.

```csharp
public interface IPCB_MasterLayerStack : IPCB_LayerStackBase
```

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

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

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

## Remarks

Obtain it from [`IPCB_Board.MasterStack`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#masterstack). [`IPCB_Board.LayerStack_V7`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#layerstack_v7) is backed by the same master stack.

Each substack is an [`IPCB_LayerStack`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md) in which a layer of the master stack is enabled or disabled. Pads, vias and board regions are assigned to a substack.

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [LayerStackStyle](#layerstackstyle) | [TLayerStackStyle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TLayerStackStyle.md) | get; set | The layer stacking style of the board. |
| [Substacks](#substacks) | [IPCB_LayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md) | get | The substack at an index. |

### LayerStackStyle

The layer stacking style of the board.

```csharp
TLayerStackStyle GetState_LayerStackStyle();
void SetState_LayerStackStyle(TLayerStackStyle argStackStyle);
```

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

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

A new master stack has the style `TLayerStackStyle.eLayerStack_Pairs`.

### Substacks

The substack at an index.

```csharp
IPCB_LayerStack GetState_Substacks(int argIndex);
```

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

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

Valid indexes run from 0 to [`SubstackCount`](#substackcount) minus 1.

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [Board](#board) | [IPCB_Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md) | Returns the board that owns the master stack, or null when there is none. |
| [CreateLayer](#createlayer) | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | Returns a layer object for a layer [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id), creating it when needed. |
| [CreateSubstack](#createsubstack) | [IPCB_LayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md) | Creates a substack and adds it at the end of the master stack's substacks. |
| [DisableLayer](#disablelayer) | `void` | Disables a layer of the master stack in a substack. |
| [EnableLayer](#enablelayer) | `void` | Enables a layer of the master stack in a substack. |
| [Export_ToParameters](#export_toparameters) | `void` | Writes the definition of the master stack to a parameter string. |
| [GetSubstack](#getsubstack) | [IPCB_LayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md) | Returns the substack with the given [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id), or null when there is none. |
| [GetSubstack_1](#getsubstack_1) | [IPCB_LayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md) | Returns the first substack whose layers of a layer class are exactly the layers of a layer set, or null when no substack matches. |
| [Import_FromParameters](#import_fromparameters) | `void` | Reads the definition of the master stack from a parameter string. |
| [InsertAbove](#insertabove) | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | Inserts a layer into the master stack above a reference layer. |
| [InsertBelow](#insertbelow) | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | Inserts a layer into the master stack below a reference layer. |
| [InsertOnBottom](#insertonbottom) | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | Inserts a layer at the bottom of the master stack. |
| [InsertOnTop](#insertontop) | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | Inserts a layer at the top of the master stack. |
| [RemoveLayer](#removelayer) | `bool` | Removes a layer from the master stack. |
| [RemoveSubstack](#removesubstack) | `bool` | Removes a substack from the master stack. |
| [SubstackCount](#substackcount) | `int` | Returns the number of substacks in the master stack. |

### Board

Returns the board that owns the master stack, or null when there is none.

```csharp
IPCB_Board Board();
```

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

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

### CreateLayer

Returns a layer object for a layer [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id), creating it when needed.

```csharp
IPCB_LayerObject CreateLayer(V7_LayerBase argLayer);
```

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

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

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

Returns a layer object created earlier for that [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id) that is not in the stack (for example a removed one); otherwise creates a new one with default properties. The layer is not placed in the stack: insert it with [`InsertOnTop`](#insertontop), [`InsertOnBottom`](#insertonbottom), [`InsertAbove`](#insertabove) or [`InsertBelow`](#insertbelow).

### CreateSubstack

Creates a substack and adds it at the end of the master stack's substacks.

```csharp
IPCB_LayerStack CreateSubstack();
```

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

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

The new substack gets a new unique [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id) and the name `Stack<n>`, with the lowest `n` (starting at 0) that no other substack uses.

### DisableLayer

Disables a layer of the master stack in a substack.

```csharp
void DisableLayer(IPCB_LayerStack argSubstack, IPCB_LayerObject argLayer);
void DisableLayer(object argSubstack, object argLayer);
```

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

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

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

Does nothing when the layer is not in the master stack.

### EnableLayer

Enables a layer of the master stack in a substack.

```csharp
void EnableLayer(IPCB_LayerStack argSubstack, IPCB_LayerObject argLayer);
void EnableLayer(object argSubstack, object argLayer);
```

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

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

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

Does nothing when the layer is not in the master stack.

### Export_ToParameters

Writes the definition of the master stack to a parameter string.

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

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

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

The string holds the stack in every format the current version writes, so it can be read back with [`Import_FromParameters`](#import_fromparameters).

### GetSubstack

Returns the substack with the given [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id), or null when there is none.

```csharp
IPCB_LayerStack GetSubstack(string argSubstackID);
```

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

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

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

IDs are compared without regard to case.

### GetSubstack_1

Returns the first substack whose layers of a layer class are exactly the layers of a layer set, or null when no substack matches.

```csharp
IPCB_LayerStack GetSubstack_1(IPCB_LayerSet argSet, TLayerClassID argT);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argSet` | [IPCB_LayerSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerSet.md) | value |  |
| `argT` | [TLayerClassID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TLayerClassID.md) | value | The layer class to compare, for example `TLayerClassID.eLayerClass_Signal`. |

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

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

Layers of other classes are ignored.

### Import_FromParameters

Reads the definition of the master stack from a parameter string.

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

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

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

Throws an exception when the version of the parameters is not supported.

### InsertAbove

Inserts a layer into the master stack above a reference layer.

```csharp
IPCB_LayerObject InsertAbove(IPCB_LayerObject argRefLayer, IPCB_LayerObject argLayer);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argRefLayer` | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | value | The layer to insert above. When it is not in the stack, the layer is inserted on top. |
| `argLayer` | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | value |  |

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

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

Returns the inserted layer, or null when the layer is not inserted: it belongs to another master stack, it is already in the stack, or it is an electrical layer whose layer [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id) is already in the stack. The inserted layer is disabled in every substack.

### InsertBelow

Inserts a layer into the master stack below a reference layer.

```csharp
IPCB_LayerObject InsertBelow(IPCB_LayerObject argRefLayer, IPCB_LayerObject argLayer);
```

| Parameter | Type | Passing | Description |
| --- | --- | --- | --- |
| `argRefLayer` | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | value | The layer to insert below. When it is not in the stack, the layer is inserted at the bottom. |
| `argLayer` | [IPCB_LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObject.md) | value |  |

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

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

Returns the inserted layer, or null when the layer is not inserted: it belongs to another master stack, it is already in the stack, or it is an electrical layer whose layer [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id) is already in the stack. The inserted layer is disabled in every substack.

### InsertOnBottom

Inserts a layer at the bottom of the master stack.

```csharp
IPCB_LayerObject InsertOnBottom(IPCB_LayerObject argLayer);
```

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

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

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

Returns the inserted layer, or null when the layer is not inserted: it belongs to another master stack, it is already in the stack, or it is an electrical layer whose layer [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id) is already in the stack. The inserted layer is disabled in every substack.

### InsertOnTop

Inserts a layer at the top of the master stack.

```csharp
IPCB_LayerObject InsertOnTop(IPCB_LayerObject argLayer);
```

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

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

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

Returns the inserted layer, or null when the layer is not inserted: it belongs to another master stack, it is already in the stack, or it is an electrical layer whose layer [`ID`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id) is already in the stack. The inserted layer is disabled in every substack.

### RemoveLayer

Removes a layer from the master stack.

```csharp
bool RemoveLayer(IPCB_LayerObject argLayer);
bool RemoveLayer(object argLayer);
```

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

**Returns:** `bool`

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

Returns false when the layer belongs to another master stack. A mechanical layer is not removed: for one of the mechanical layers that the master stack creates by default the call sets [`IPCB_MechanicalLayer.MechLayerEnabled`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MechanicalLayer.md#mechlayerenabled) to false and returns true; for any other mechanical layer it returns false. Any other layer is removed from the stack and from every substack, and the call returns true.

### RemoveSubstack

Removes a substack from the master stack.

```csharp
bool RemoveSubstack(IPCB_LayerStack argSubstack);
bool RemoveSubstack(object argSubstack);
```

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

**Returns:** `bool`

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

Pads, vias and board regions that use the substack are assigned another substack of the master stack, if there is one. The substack's data is removed from [`IPCB_MaxMinWidthConstraint`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MaxMinWidthConstraint.md) and [`IPCB_DifferentialPairsRoutingRule`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_DifferentialPairsRoutingRule.md) rules, and its trace impedances are removed from the impedance profiles. Does nothing when the master stack has no board.

### SubstackCount

Returns the number of substacks in the master stack.

```csharp
int SubstackCount();
```

**Returns:** `int`

## Inherited members

- From [IPCB_LayerStackBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md): [Count](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#count), [Count_1](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#count_1), [Count_2](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#count_2), [First](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#first), [ID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#id), [IsFlex](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#isflex), [Iterator](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#iterator), [Iterator_1](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#iterator_1), [Iterator_2](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#iterator_2), [Last](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#last), [Name](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#name), [Next](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#next), [Previous](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#previous), [StateID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#stateid), [ZBottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#zbottom), [ZTop](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#ztop)

## Returned by

[IPCB_Board.MasterStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#masterstack), [IPCB_ImpedanceProfile.MasterLayerStack](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_ImpedanceProfile.md#masterlayerstack)
