---
title: "DrcViolation"
description: "A single design rule checking violation."
canonical_url: "https://www.rosette.dev/docs/api-reference/DrcViolation"
markdown_url: "https://www.rosette.dev/docs/api-reference/DrcViolation.md"
source_url: "https://github.com/PreFab-Photonics/rosette/blob/f086d7670645fd36c05362d696d442a2b2e74850/www/content/docs/api-reference/DrcViolation.mdx"
docs_channel: "main"
docs_revision: "f086d7670645fd36c05362d696d442a2b2e74850"
---

# DrcViolation

A single DRC violation.

Import with `from rosette.drc import DrcViolation`.

Returned as part of a `DrcResult` after running `run_drc()`. Each violation
describes a specific rule failure, including the rule name, affected layer(s),
severity, and a bounding box around the offending geometry.

```python
result = run_drc(cell, rules)
for v in result.violations:
    print(f"[{v.severity}] {v.rule_type} on {v.layer}: {v.message}")
```

## Attributes



### `rule_name`

```python
rule_name: str | None
```

Name of the rule that was violated, or `None` if the rule was not named.





### `message`

```python
message: str
```

Human-readable description of the violation.





### `severity`

```python
severity: str
```

Severity level: `"error"` or `"warning"`.





### `rule_type`

```python
rule_type: str
```

Type of the DRC rule that was violated (e.g., `"min_width"`, `"min_spacing"`).





### `layer`

```python
layer: tuple[int, int]
```

The `(number, datatype)` of the primary layer involved in the violation.





### `layer2`

```python
layer2: tuple[int, int] | None
```

The `(number, datatype)` of the second layer, for inter-layer rules (e.g.,
spacing, enclosure). `None` for single-layer rules.





### `bbox`

```python
bbox: tuple[tuple[float, float], tuple[float, float]]
```

Bounding box of the violation as `((min_x, min_y), (max_x, max_y))`.

**Coordinate frame:** top-level (flattened, global) coordinates, the same
frame as the final GDS output. Violations raised inside a nested cell are
reported at the cell's placed position, not in its local coordinate system.
This contract holds for every rule type.





### `cell_name`

```python
cell_name: str | None
```

Name of the cell containing the polygon that triggered the violation.

Populated for every attributable violation: all per-polygon rules
(`min_width`, `min_area`, `allowed_angles`, `min_edge_length`,
`self_intersection`, `max_width`, `acute_angle`, `snap_to_grid`), all
same-layer and cross-layer pairwise rules, and `not_inside` (set to the
inner-layer cell). The only rule type that leaves `cell_name` as `None` by
design is `density`, which is a window-level check with no single source
polygon.





### `cell_name2`

```python
cell_name2: str | None
```

Name of the cell containing the second polygon involved in the violation.

For intra-cell same-layer pairwise violations (both polygons inside the
same cell definition), this equals `cell_name`. For inter-instance or
cross-layer pairwise rules, it identifies the other cell. `None` for
per-polygon rules and for cases where the second side is undefined. Examples:
an `enclosure` violation with no outer polygon on the layer, a
`require_overlap` miss (no matching polygon), or a `not_inside` violation
(which unions all outer polygons before testing).