Drc#

class pyedb.workflows.drc.drc.Drc(edb: pyedb.Edb)#

High-performance DRC engine for PyEDB.

This class provides a multi-threaded design rule checker that runs inside an open PyEDB session. It uses R-tree spatial indexing for efficient geometry queries and parallelizes all rule checks using ThreadPoolExecutor.

Parameters:
edbpyedb.Edb

Active EDB session that must already be open.

Attributes:
edbpyedb.Edb

Reference to the EDB instance.

violationslist of dict

List of violation dictionaries populated by check().

idx_primitivesrtree.index.Index

R-tree spatial index for primitive geometries.

idx_viasrtree.index.Index

R-tree spatial index for via locations.

idx_componentsrtree.index.Index

R-tree spatial index for component bounding boxes.

Examples

Basic DRC workflow:

>>> import pyedb
>>> from pyedb.workflows.drc.drc import Drc, Rules
>>> edb = pyedb.Edb("my_board.aedb")
>>> rules = Rules.parse_file("rules.json")
>>> drc = Drc(edb)
>>> violations = drc.check(rules)
>>> print(f"Found {len(violations)} violations")

Export to IPC-356A format:

>>> drc.to_ipc356a("review.ipc")

Overview#

check

Run all rules and return a list of violations.

to_ipc356a

Write a complete IPC-D-356A netlist with DRC annotations.

Import detail#

from pyedb.workflows.drc.drc import Drc

Attribute detail#

Drc.edb#
Drc.violations: list[dict[str, Any]] = []#

Method detail#

Drc.check(rules: Rules) list[dict[str, Any]]#

Run all rules and return a list of violations.

This method dispatches each rule to its appropriate handler and collects all violations. Successive calls overwrite previous results.

Parameters:
rulesRules

Validated rule container with design constraints.

Returns:
list of dict

Each dictionary describes a single violation with keys:

  • rule : Rule type (e.g., "minLineWidth")

  • limit_um : Limit value in micrometers

  • Additional rule-specific keys (layer, net1, primitive, etc.)

Examples

>>> rules = Rules().add_min_line_width("trace", "3.5mil")
>>> drc = Drc(edb)
>>> violations = drc.check(rules)
>>> for v in violations:
...     print(f"{v['rule']}: {v}")
Drc.to_ipc356a(file_path: str) None#

Write a complete IPC-D-356A netlist with DRC annotations.

This method exports the full netlist in IPC-D-356A format with all detected violations appended as comment lines. The file can be imported by CAM tools (Valor, Genesis, etc.) for fabrication review.

Parameters:
file_pathstr

Output file path. Overwrites existing files without warning.

Notes

  • File format follows IPC-D-356A specification

  • Violations are appended as comment lines starting with C

  • Includes netlist information (nets, primitives, padstack instances)

  • Compatible with major CAM software packages

Examples

>>> drc = Drc(edb)
>>> violations = drc.check(rules)
>>> drc.to_ipc356a("fab_review.ipc")

Export with violations:

>>> rules = Rules().add_min_line_width("trace", "3mil")
>>> drc = Drc(edb)
>>> drc.check(rules)
>>> drc.to_ipc356a("review_with_violations.ipc")