
# IPCB_LayerObject interface

A layer of a PCB document, with its layer ID, its name and whether primitives use it.

```csharp
public interface IPCB_LayerObject
```

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

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

## Remarks

Layer objects come from the layer stacks of the board, for example from [`IPCB_LayerStack.LayerObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md#layerobject), [`IPCB_LayerStack_V7.LayerObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack_V7.md#layerobject), the layer walk of [`IPCB_LayerStack_V7`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack_V7.md) (`FirstLayer`, `NextLayer`) or an [`IPCB_LayerObjectIterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObjectIterator.md) from [`IPCB_LayerStackBase.Iterator`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#iterator). Each kind of layer has its own derived interface, such as [`IPCB_SignalLayer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_SignalLayer.md), [`IPCB_InternalPlane`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_InternalPlane.md), [`IPCB_DielectricLayer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_DielectricLayer.md) and [`IPCB_MechanicalLayer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MechanicalLayer.md).

[`IPCB_LayerStack.LayerObject`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md#layerobject) returns a layer object for any layer of the board, also for a layer that is not in the layer stack, such as a keep-out layer or a mechanical layer.

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [LayerDisplayName](#layerdisplayname) | `string` | get | The name of the layer in a given format. |
| [LayerName](#layername) | `string` | get; set | The name of the layer. |
| [UsedByPrims](#usedbyprims) | `bool` | get; set | Whether the layer is marked as used by primitives. |

### LayerDisplayName

The name of the layer in a given format.

```csharp
string GetState_LayerDisplayName(TLayerNameDisplayMode argValue);
```

**Type:** `string` · **Access:** read-only · **Index:** `argValue` ([TLayerNameDisplayMode](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TLayerNameDisplayMode.md)): The format. `TLayerNameDisplayMode.eLayerNameDisplay_Short` and `TLayerNameDisplayMode.eLayerNameDisplay_Medium` give the short and the medium standard name of the layer; `TLayerNameDisplayMode.eLayerNameDisplay_Long` gives [`LayerName`](#layername).

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

A coverlay layer takes its name from the solder mask layer it is linked to, in every format.

On a rigid-flex board with more than one substack, a mechanical layer of a paired kind that is used in a mechanical layer pair gets a suffix in parentheses: the index of the pair's substack in the short and medium formats, the substack's name in the long format.

### LayerName

The name of the layer.

```csharp
string GetState_LayerName();
void SetState_LayerName(string argName);
```

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

While the stored name is empty, for example after an empty name is set, it is the standard name of the layer. Setting the name has no effect on the layer that is the board's [`IPCB_Board.RouteToolPathLayer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#routetoolpathlayer).

### UsedByPrims

Whether the layer is marked as used by primitives.

```csharp
bool GetState_UsedByPrims();
void SetState_UsedByPrims(bool argValue);
```

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

The value is a stored flag: reading it does not check the board for primitives, and setting it changes only the flag. [`IPCB_Board.LayerIsUsed`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#layerisused) reads and sets the same flag for a layer of the board.

**Example:** Report which mechanical layers of the current board are enabled, displayed and used.

```csharp
using PCB;

IPCB_Board board = PCB.GlobalVars.PCBServer?.GetCurrentPCBBoard();
if (board == null)
    return;
IPCB_LayerStack ls = board.GetState_LayerStack();
if (ls == null)
    return;
string s = "";
for (TV6_Layer layer = TV6_Layer.eV6_Mechanical1; layer <= TV6_Layer.eV6_Mechanical16; layer++)
{
    var lObject = ls.LayerObject(layer) as IPCB_MechanicalLayer;
    if (lObject == null)
        continue;
    // If a mechanical layer is not enabled (as per the Board Layers and
    // Colors dialog) then this layer cannot be displayed nor have any objects on it.
    if (!lObject.GetState_MechLayerEnabled())
        s = s + lObject.GetState_LayerName() + " is NOT enabled (thus it cannot be displayed nor have any objects on it)." + "\r";
    else
    {
        bool isDisplayed = board.GetState_LayerIsDisplayed(lObject.V7_LayerID());
        if (isDisplayed && lObject.GetState_UsedByPrims())
            s = s + lObject.GetState_LayerName() + " is displayed and there are objects on it." + "\r";
        if (isDisplayed && !lObject.GetState_UsedByPrims())
            s = s + lObject.GetState_LayerName() + " is displayed and there are NO objects on it." + "\r";
        if (!isDisplayed && lObject.GetState_UsedByPrims())
            s = s + lObject.GetState_LayerName() + " is NOT displayed and there are objects on it." + "\r";
        if (!isDisplayed && !lObject.GetState_UsedByPrims())
            s = s + lObject.GetState_LayerName() + " is NOT displayed and there are NO objects on it." + "\r";
    }
}
DXP.Utils.ShowMessage(s);
```

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [IsInLayerStack](#isinlayerstack) | `bool` | Returns whether the layer is in the layer stack of its board. |
| [LayerStack](#layerstack) | [IPCB_LayerStackBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md) |  |
| [V6_LayerID](#v6_layerid) | [TV6_Layer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TV6_Layer.md) | Returns the layer ID of the layer as a [`TV6_Layer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TV6_Layer.md) value. |
| [V7_LayerID](#v7_layerid) | [V7_LayerBase](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/V7_LayerBase.md) | Returns the layer ID of the layer. |

### IsInLayerStack

Returns whether the layer is in the layer stack of its board.

```csharp
bool IsInLayerStack();
```

**Returns:** `bool`

Returns false for a layer that does not belong to a layer stack.

### LayerStack

*No description yet.*

```csharp
IPCB_LayerStackBase LayerStack();
```

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

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

### V6_LayerID

Returns the layer ID of the layer as a [`TV6_Layer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TV6_Layer.md) value.

```csharp
TV6_Layer V6_LayerID();
```

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

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

[`TV6_Layer`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/TV6_Layer.md) has values only for mid layers 1 to 30, internal planes 1 to 16 and mechanical layers 1 to 16, and none for dielectric layers; use [`V7_LayerID`](#v7_layerid) for other layers.

### V7_LayerID

Returns the layer ID of the layer.

```csharp
V7_LayerBase V7_LayerID();
```

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

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

## Returned by

[IPCB_DrillLayerPair.StartLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_DrillLayerPair.md#startlayer), [IPCB_DrillLayerPair.StopLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_DrillLayerPair.md#stoplayer), [IPCB_LayerObjectIterator.LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerObjectIterator.md#layerobject), [IPCB_LayerStack.LayerObject](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md#layerobject), [IPCB_LayerStack.LayerObject_1](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStack.md#layerobject_1), [IPCB_LayerStackBase.First](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#first), [IPCB_LayerStackBase.Last](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#last), [IPCB_LayerStackBase.Next](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#next), [IPCB_LayerStackBase.Previous](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#previous), [IPCB_MasterLayerStack.CreateLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#createlayer), [IPCB_MasterLayerStack.InsertAbove](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertabove), [IPCB_MasterLayerStack.InsertBelow](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertbelow), [IPCB_MasterLayerStack.InsertOnBottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertonbottom), [IPCB_MasterLayerStack.InsertOnTop](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertontop), [IPCB_MasterLayerStack2.CreateLayerWithId](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack2.md#createlayerwithid), [IPCB_Via.StartLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Via.md#startlayer), [IPCB_Via.StopLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Via.md#stoplayer), [IPrintedElectronics.GetLowerDielectricBetweenTwoLayers](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPrintedElectronics.md#getlowerdielectricbetweentwolayers)

## Accepted by

[IPCB_Board.LayerPositionInSet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Board.md#layerpositioninset), [IPCB_LayerStackBase.Count_2](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#count_2), [IPCB_LayerStackBase.Iterator_2](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#iterator_2), [IPCB_LayerStackBase.Next](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#next), [IPCB_LayerStackBase.Previous](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#previous), [IPCB_LayerStackBase.ZBottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#zbottom), [IPCB_LayerStackBase.ZTop](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_LayerStackBase.md#ztop), [IPCB_MasterLayerStack.DisableLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#disablelayer), [IPCB_MasterLayerStack.EnableLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#enablelayer), [IPCB_MasterLayerStack.InsertAbove](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertabove), [IPCB_MasterLayerStack.InsertBelow](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertbelow), [IPCB_MasterLayerStack.InsertOnBottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertonbottom), [IPCB_MasterLayerStack.InsertOnTop](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#insertontop), [IPCB_MasterLayerStack.RemoveLayer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MasterLayerStack.md#removelayer)
