Skip to content

Utilities

altium_api.utils

ERC utility functions for Altium API.

classify_component

classify_component(component: Component) -> ComponentClassification | None

Classify a component into a known functional category.

Parameters:

Name Type Description Default
component Component

The component to classify.

required

Returns:

Type Description
ComponentClassification | None

A ComponentClassification value, or None if no category could be determined.

classify_interface

classify_interface(net_name: str) -> str

Infers the signal interface type from a net name.

Parameters:

Name Type Description Default
net_name str

The name of the net.

required

Returns:

Type Description
str

A lowercase interface type string: 'usb', 'hdmi', 'ethernet', 'can',

str

or 'default' if no known interface is recognised.

collect_component_pin_ids

collect_component_pin_ids(component: Component) -> set[str]

Returns the set of unique pin IDs belonging to a component.

Parameters:

Name Type Description Default
component Component

A component object.

required

Returns:

Type Description
set[str]

Set of unique pin ID strings across all component parts.

find_diff_pair_partner_name

find_diff_pair_partner_name(net_name: str) -> str | None

Returns the complementary net name for a differential pair signal.

Parameters:

Name Type Description Default
net_name str

The name of one net in a differential pair (e.g. "USB_DP").

required

Returns:

Type Description
str | None

The partner net name (e.g. "USB_DN"), or None if the net name does not

str | None

match a recognised differential pair pattern.

get_default_capacitance_limit

get_default_capacitance_limit(net: Net) -> float

Returns the default TVS capacitance limit for the given net.

Parameters:

Name Type Description Default
net Net

The net to evaluate.

required

Returns:

Type Description
float

Capacitance limit in pF for the inferred interface type.

get_param_value

get_param_value(component: Component, aliases: str | list[str]) -> str | None

Returns the raw string value of the first matching parameter on a component.

Parameters:

Name Type Description Default
component Component

A component object with parameters.

required
aliases str | list[str]

A parameter alias string or list of alias strings to search for (case-insensitive).

required

Returns:

Type Description
str | None

The stripped string value of the first matching parameter, or None if not found.

is_connected_to_net

is_connected_to_net(component: Component, net: Net) -> bool

Checks whether a component is connected to a given net.

Parameters:

Name Type Description Default
component Component

The component to evaluate.

required
net Net

The target net.

required

Returns:

Type Description
bool

True if at least one component-connected net matches the target net,

bool

otherwise False.

is_board_to_board_or_mounting

is_board_to_board_or_mounting(component: Component) -> bool

Determines whether a component is a board-to-board connector or a mounting hole.

Parameters:

Name Type Description Default
component Component

A component object.

required

Returns:

Type Description
bool

True if the component is identified as a board-to-board connector or

bool

mounting hole, False otherwise.

is_chassis_net

is_chassis_net(net: Net) -> bool

Determines whether a net is a chassis or shield ground net based on its name.

Parameters:

Name Type Description Default
net Net

The net to evaluate.

required

Returns:

Type Description
bool

True if the net name matches a known chassis net name (e.g. CHASSIS,

bool

SHIELD, GND_CHASSIS), False otherwise.

is_ground_net

is_ground_net(net: Net) -> bool

Determines whether a net is a ground net based on its name.

Parameters:

Name Type Description Default
net Net

The net to evaluate.

required

Returns:

Type Description
bool

True if the net name matches a known ground net name (e.g. GND, AGND,

bool

PGND, CHASSIS, SGND, VSS, GND_CHASSIS, SHIELD), False otherwise.

is_power_net

is_power_net(net: Net) -> bool

Determines whether a net is a power supply net based on its name.

Parameters:

Name Type Description Default
net Net

The net to evaluate.

required

Returns:

Type Description
bool

True if the net name matches a known power net pattern (e.g. VCC, VDD,

bool

3V3, 5V0, VBUS), False otherwise.

is_usb_net

is_usb_net(net: Net) -> bool

Determines whether a net is a USB data net based on its name.

Parameters:

Name Type Description Default
net Net

The net to evaluate.

required

Returns:

Type Description
bool

True if the net name matches a known USB data net pattern, False otherwise.

parse_param_float

parse_param_float(component: Component, aliases: list[str]) -> float | None

Returns the float value of the first matching parameter on a component.

Parameters:

Name Type Description Default
component Component

A component object with parameters.

required
aliases list[str]

A list of parameter name strings to search for (case-insensitive).

required

Returns:

Type Description
float | None

The parsed float value, or None if the parameter is missing or unparseable.

try_get_net_voltage

try_get_net_voltage(net: Net) -> float

Attempts to determine the operating voltage of a net.

Parameters:

Name Type Description Default
net Net

The net whose voltage is to be determined.

required

Returns:

Type Description
float

The operating voltage as a float, or 0 if it cannot be determined.

try_parse_voltage

try_parse_voltage(value: str) -> float | None

Attempts to parse a numeric string with optional SI suffix into a float.

Parameters:

Name Type Description Default
value str

A string representing a numeric value with optional unit suffix.

required

Returns:

Type Description
float | None

The parsed float value, or None if parsing fails or input is empty.

ComponentClassification

Bases: Enum

Functional classification of a schematic component.

ComponentClassification values returned by classify_component(component):

Enum member Serialized value
TVS_ESD "tvs_esd"
CONNECTOR "connector"
CMC "cmc"
RESISTOR "resistor"
CAPACITOR "capacitor"
IC "ic"
DIODE "diode"

Constants

BOARD_TO_BOARD_KEYWORDS module-attribute

BOARD_TO_BOARD_KEYWORDS = ['board-to-board', 'board to board', 'b2b', 'btb', 'mezzanine', 'stacking', 'df12', 'df40', 'df30', 'df17', 'df9', 'df11', 'df13', 'slimstack', 'fpc', 'ffc']

CAPACITOR_COMMENT_KEYWORDS module-attribute

CAPACITOR_COMMENT_KEYWORDS = ['capacitor', 'cap', 'bypass', 'decoupling', 'decoupler', 'filter']

CAPACITOR_DESIGNATOR_PREFIXES module-attribute

CAPACITOR_DESIGNATOR_PREFIXES = ('C',)

CHASSIS_NET_NAMES module-attribute

CHASSIS_NET_NAMES = {'CHASSIS', 'SHIELD', 'GND_CHASSIS'}

CMC_COMMENT_KEYWORDS module-attribute

CMC_COMMENT_KEYWORDS = ['common mode', 'cmc', 'choke']

CMC_DESIGNATOR_PREFIXES module-attribute

CMC_DESIGNATOR_PREFIXES = ('L', 'FL', 'CM')

CONNECTOR_COMMENT_KEYWORDS module-attribute

CONNECTOR_COMMENT_KEYWORDS = ['connector', 'header', 'jack', 'plug', 'socket', 'terminal', 'usb', 'rj45', 'hdmi', 'receptacle']

CONNECTOR_DESIGNATOR_PREFIXES module-attribute

CONNECTOR_DESIGNATOR_PREFIXES = ('J', 'P', 'X', 'CN')

DEFAULT_CAPACITANCE_LIMITS module-attribute

DEFAULT_CAPACITANCE_LIMITS = {'usb': 1.0, 'hdmi': 0.5, 'ethernet': 5.0, 'can': 15.0, 'default': 5.0}

DIFF_PAIR_SUFFIXES module-attribute

DIFF_PAIR_SUFFIXES = (('_P', '_N'), ('_DP', '_DN'), ('+', '-'), ('_PLUS', '_MINUS'), ('P', 'N'))

GROUND_NET_NAMES module-attribute

GROUND_NET_NAMES = {'GND', 'AGND', 'PGND', 'CHASSIS', 'SGND', 'VSS', 'GND_CHASSIS', 'SHIELD'}

IC_DESIGNATOR_PREFIXES module-attribute

IC_DESIGNATOR_PREFIXES = ('U', 'IC')

MOUNTING_HOLE_DESIGNATOR_PREFIXES module-attribute

MOUNTING_HOLE_DESIGNATOR_PREFIXES = ('PTH', 'MH')

MOUNTING_HOLE_KEYWORDS module-attribute

MOUNTING_HOLE_KEYWORDS = ['mounting', 'standoff', 'spacer', 'pth-m', 'screw']

RESISTOR_COMMENT_KEYWORDS module-attribute

RESISTOR_COMMENT_KEYWORDS = ['resistor']

RESISTOR_DESIGNATOR_PREFIXES module-attribute

RESISTOR_DESIGNATOR_PREFIXES = ('R',)

TVS_ESD_COMMENT_KEYWORDS module-attribute

TVS_ESD_COMMENT_KEYWORDS = ['tvs', 'esd', 'varistor', 'suppressor', 'transient', 'protection diode', 'tpd', 'pesd', 'cdsot', 'smda', 'sp05', 'usblc', 'prtr', 'ip4']

TVS_ESD_DESIGNATOR_PREFIXES module-attribute

TVS_ESD_DESIGNATOR_PREFIXES = ('TVS', 'Z', 'RV')

USB_NET_PATTERN module-attribute

USB_NET_PATTERN = compile('(?i)(USB.*[DP][+\\-NP]|USB_[NP]|USB_D[+\\-NP]|D[+\\-].*USB|USB.*DATA)')