Rules#

class pyedb.workflows.drc.drc.Rules(*, min_line_width: list[MinLineWidth] = [], min_clearance: list[MinClearance] = [], min_annular_ring: list[MinAnnularRing] = [], diff_pair_length_match: list[DiffPairLengthMatch] = [], back_drill_stub_length: list[BackDrillStubLength] = [], copper_balance: list[CopperBalance] = [])#

Centralized container for all design rule categories.

This class provides a type-safe, serializable container for design rules with JSON/YAML round-trip support and a fluent API for building rule decks.

Attributes:
min_line_widthlist of MinLineWidth

Minimum acceptable trace width rules per layer or globally.

min_clearancelist of MinClearance

Spacing requirements between nets (wildcards allowed).

min_annular_ringlist of MinAnnularRing

Minimum annular ring requirements for drilled holes.

diff_pair_length_matchlist of DiffPairLengthMatch

Length matching constraints for differential pairs.

back_drill_stub_lengthlist of BackDrillStubLength

Maximum allowed back-drill stub length constraints.

copper_balancelist of CopperBalance

Copper density balance limits per layer or zone.

Examples

Build rules programmatically:

>>> rules = (
...     Rules()
...     .add_min_line_width("pwr", "15mil")
...     .add_min_clearance("clk2data", "4mil", "CLK*", "DATA*")
...     .add_min_annular_ring("via5", "5mil")
...     .add_copper_balance("top_bal", max_percent=10, layers=["TOP"])
... )

Load from JSON file:

>>> rules = Rules.parse_file("my_rules.json")

Export to JSON:

>>> rules.model_dump_json(indent=2)

Methods

Rules.add_back_drill_stub_length(name, value)

Append a maximum back-drill stub length rule.

Rules.add_copper_balance(name, max_percent, ...)

Append a copper density balance rule.

Rules.add_diff_pair_length_match(name, ...)

Append a differential pair length matching rule.

Rules.add_min_annular_ring(name, value)

Append a minimum annular ring rule for drilled holes.

Rules.add_min_clearance(name, value, net1, net2)

Append a minimum clearance rule between nets.

Rules.add_min_line_width(name, value[, layers])

Append a minimum line width rule.

Rules.construct([_fields_set])

Rules.copy(*[, include, exclude, update, deep])

Returns a copy of the model.

Rules.dict(*[, include, exclude, by_alias, ...])

Rules.from_dict(data)

Create Rules instance from dictionary.

Rules.from_orm(obj)

Rules.json(*[, include, exclude, by_alias, ...])

Rules.model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

Rules.model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

Rules.model_dump(*[, mode, include, ...])

!!! abstract "Usage Documentation"

Rules.model_dump_json(*[, indent, ...])

!!! abstract "Usage Documentation"

Rules.model_json_schema([by_alias, ...])

Generates a JSON schema for a model class.

Rules.model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

Rules.model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

Rules.model_rebuild(*[, force, ...])

Try to rebuild the pydantic-core schema for the model.

Rules.model_validate(obj, *[, strict, ...])

Validate a pydantic model instance.

Rules.model_validate_json(json_data, *[, ...])

!!! abstract "Usage Documentation"

Rules.model_validate_strings(obj, *[, ...])

Validate the given object with string data against the Pydantic model.

Rules.parse_file(path, *[, content_type, ...])

Rules.parse_obj(obj)

Rules.parse_raw(b, *[, content_type, ...])

Rules.schema([by_alias, ref_template])

Rules.schema_json(*[, by_alias, ref_template])

Rules.to_dict()

Convert Rules to dictionary.

Rules.update_forward_refs(**localns)

Rules.validate(value)

Attributes