
# IPCB_Violation interface

A design rule violation on a PCB document, the rule that is broken and the object, or pair of objects, that break it.

```csharp
public interface IPCB_Violation : IPCB_Primitive
```

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

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

## Remarks

A violation of a binary design rule refers to two objects, `Primitive1` and `Primitive2`; a violation of a unary design rule refers to one object, `Primitive1`, and `Primitive2` is null. Check `Primitive2` before using it. `Rule` returns the rule, and `Name` and `Description` describe the violation. Violations are returned by the rule checks of [`IPCB_Rule`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Rule.md), such as [`IPCB_Rule.ActualCheck`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Rule.md#actualcheck).

## Properties

| Property | Type | Access | Description |
| --- | --- | --- | --- |
| [Description](#description) | `string` | get | The description of the violation. |
| [Name](#name) | `string` | get | The name of the violation. |
| [Primitive1](#primitive1) | [IPCB_Primitive](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md) | get | The first object of the violation, or the only object for a violation of a unary rule. |
| [Primitive2](#primitive2) | [IPCB_Primitive](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md) | get | The second object of the violation; null for a violation of a unary rule. |
| [Rule](#rule) | [IPCB_Primitive](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md) | get | The design rule that the violation breaks. |
| [ShortDescriptorString](#shortdescriptorstring) | `string` | get | A short description of the violation, which starts with the kind of the rule and names the objects of the violation. |

### Description

The description of the violation.

```csharp
string GetState_Description();
```

**Type:** `string` · **Access:** read-only

The description is part of the violation's [`DescriptorString`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#descriptorstring).

**See also:** [IPCB_Violation.Name](#name)

### Name

The name of the violation.

```csharp
string GetState_Name();
```

**Type:** `string` · **Access:** read-only

The name is a number with at least four digits that increases with each violation created, followed by a colon, a space and the object kind of `Primitive1`, such as `Track`, or the object kinds of `Primitive1` and `Primitive2` separated by a slash with a space on each side. For a violation of a single object that is a net, the net's name follows in parentheses.

**See also:** [IPCB_Violation.Description](#description)

### Primitive1

The first object of the violation, or the only object for a violation of a unary rule.

```csharp
IPCB_Primitive GetState_Primitive1();
```

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

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

For a back-drill via the property returns the via it was drilled from, and for a region of a solid polygon it returns the polygon.

### Primitive2

The second object of the violation; null for a violation of a unary rule.

```csharp
IPCB_Primitive GetState_Primitive2();
```

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

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

For a back-drill via the property returns the via it was drilled from, and for a region of a solid polygon it returns the polygon.

### Rule

The design rule that the violation breaks.

```csharp
IPCB_Primitive GetState_Rule();
```

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

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

The rule is returned as an [`IPCB_Primitive`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md); the object is an [`IPCB_Rule`](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Rule.md).

**Example:** Show the name, description and design rule of every violation on the current board.

```csharp
using PCB;

IPCB_Board board = PCB.GlobalVars.PCBServer?.GetCurrentPCBBoard();
if (board == null)
    return;

// Create an iterator that looks for violation objects only.
IPCB_BoardIterator iterator = board.BoardIterator_Create();
iterator.AddFilter_ObjectSet(new PCB.TObjectSet { TObjectId.eViolationObject });
iterator.AddFilter_AllLayers();
iterator.AddFilter_Method(TIterationMethod.eProcessAll);

// Search for violations.
var violation = iterator.FirstPCBObject() as IPCB_Violation;
while (violation != null)
{
    string s = "Violation Name: " + violation.GetState_Name() + "\r\n" +
               "Description: " + violation.GetState_Description();
    // Get the design rule associated with the current violation.
    var rule = violation.GetState_Rule() as IPCB_Rule;
    if (rule != null)
        DXP.Utils.ShowInfo(s + "\r\n" + " Rule Name: " + rule.GetState_Name(), "Violation");
    s = "";
    violation = iterator.NextPCBObject() as IPCB_Violation;
}
board.BoardIterator_Destroy(ref iterator);
```

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

### ShortDescriptorString

A short description of the violation, which starts with the kind of the rule and names the objects of the violation.

```csharp
string GetState_ShortDescriptorString();
```

**Type:** `string` · **Access:** read-only

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [IsRedundant](#isredundant) | `bool` | Returns whether the violation is between an object and itself. |

### IsRedundant

Returns whether the violation is between an object and itself.

```csharp
bool IsRedundant();
```

**Returns:** `bool`

True when `Primitive1` and `Primitive2` are both set and are the same object (for a polygon, the same part of it); false otherwise, and always false for a violation of a unary rule.

## Inherited members

- From [IPCB_Primitive](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md): [AllowGlobalEdit](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#allowglobaledit), [BeginModify](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#beginmodify), [Board](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#board), [BoundingRectangle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#boundingrectangle), [BoundingRectangleChildren](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#boundingrectanglechildren), [BoundingRectangleForPainting](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#boundingrectangleforpainting), [BoundingRectangleForSelection](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#boundingrectangleforselection), [CancelModify](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#cancelmodify), [Component](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#component), [Coordinate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#coordinate), [DescriptorString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#descriptorstring), [DetailString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#detailstring), [Dimension](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#dimension), [DrawAsPreview](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#drawaspreview), [DRCError](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#drcerror), [Enabled](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled), [Enabled_Direct](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled_direct), [Enabled_vComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled_vcomponent), [Enabled_vCoordinate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled_vcoordinate), [Enabled_vDimension](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled_vdimension), [Enabled_vNet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled_vnet), [Enabled_vPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabled_vpolygon), [EnableDraw](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#enabledraw), [EndModify](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#endmodify), [Export_ToParameters](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#export_toparameters), [FlipXY](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#flipxy), [GraphicallyInvalidate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#graphicallyinvalidate), [Handle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#handle), [Identifier](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#identifier), [InBoard](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#inboard), [InComponent](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#incomponent), [InCoordinate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#incoordinate), [Index](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#index), [InDimension](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#indimension), [InNet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#innet), [InPolygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#inpolygon), [InSelectionMemory](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#inselectionmemory), [IsAssyTestPoint_Bottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#isassytestpoint_bottom), [IsAssyTestPoint_Top](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#isassytestpoint_top), [IsElectricalPrim](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#iselectricalprim), [IsFreePrimitive](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#isfreeprimitive), [IsHidden](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#ishidden), [IsKeepout](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#iskeepout), [IsPreRoute](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#ispreroute), [IsSaveable](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#issaveable), [IsTenting](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#istenting), [IsTenting_Bottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#istenting_bottom), [IsTenting_Top](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#istenting_top), [IsTestPoint_Bottom](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#istestpoint_bottom), [IsTestPoint_Top](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#istestpoint_top), [Layer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#layer), [MiscFlag1](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#miscflag1), [MiscFlag2](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#miscflag2), [MiscFlag3](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#miscflag3), [Moveable](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#moveable), [MoveByXY](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#movebyxy), [MoveToXY](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#movetoxy), [Net](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#net), [ObjectID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#objectid), [ObjectIDString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#objectidstring), [PadCacheRobotFlag](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#padcacherobotflag), [PasteMaskExpansion](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#pastemaskexpansion), [Polygon](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#polygon), [PolygonOutline](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#polygonoutline), [PowerPlaneClearance](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#powerplaneclearance), [PowerPlaneConnectStyle](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#powerplaneconnectstyle), [PowerPlaneReliefExpansion](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#powerplanereliefexpansion), [Preview](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#preview), [ReliefAirGap](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#reliefairgap), [ReliefConductorWidth](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#reliefconductorwidth), [ReliefEntries](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#reliefentries), [Replicate](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#replicate), [RequiredParamterSpace](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#requiredparamterspace), [RotateBy](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#rotateby), [Selected](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#selected), [SolderMaskExpansion](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#soldermaskexpansion), [SwapLayerPairs](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#swaplayerpairs), [TearDrop](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#teardrop), [UnionIndex](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#unionindex), [UniqueId](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#uniqueid), [UniqueID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#uniqueid-1), [Used](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#used), [UserRouted](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#userrouted), [V7Layer](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#v7layer), [ViewableObjectID](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Primitive.md#viewableobjectid)

## Returned by

[IPCB_MatchedNetLengthsConstraint.MatchLengthForFromTo](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MatchedNetLengthsConstraint.md#matchlengthforfromto), [IPCB_MatchedNetLengthsConstraint.MatchLengthForNet](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_MatchedNetLengthsConstraint.md#matchlengthfornet), [IPCB_Rule.ActualCheck](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Rule.md#actualcheck)

## Accepted by

[IPCB_Rule.ViolationDescriptorString](https://altiumdeveloper.github.io/ad-sdk-docs/reference/pcb/IPCB_Rule.md#violationdescriptorstring)
