Getting Started with Custom ERC Checks
Custom ERC Check lets you run your own Python-based Electrical Rule Check logic against project data from Altium 365.
This page is the starting point for workspace admins who want to:
- understand the execution model of a custom ERC script
- load project data such as components, pins, nets, and parameters
- report rule violations in Altium 365
- build a first working script and then extend it into a real production rule
For the complete reference, see:
How a Custom ERC Script Works
Each custom ERC script must define an onExecute(context, input_parameters) function.
At runtime, the platform calls this function and expects it to return a ValidationResult containing any violations found.
- Loads design data for the current project.
- Applies one or more validation rules.
- Adds violations to the result and returns it.
How to Add Your First Custom Script
Note: Before creating your first script, make sure your organization has a valid license for Custom ERC Checks.
To add a new custom ERC script in Altium 365:
- Open
Admin. - Go to
Customization. - Select the
Electrical Rule Checkstab. - Click
Add. - Enter a name for the new ERC check.
- In the
Assignedcolumn, clickAssignand then selectCreate Script.
The script editor opens with a default ERC script template. Save the script, then use Test Run to execute it.
When prompted, enter the target project ID, for example 35F834EB-D99C-4833-ABAC-B2217332896F.
While the script is running, use these tabs in the editor to inspect the result:
Console: developer-oriented output for progress tracking and debuggingResponse: execution result, including the violations detected for the selected project
Minimal Template
Use the following script as a starting point:
from altium import ExecutionContext
from altium_api import load_project_data, ValidationResult, ProjectData
def _sample_erc_check(project_data: ProjectData) -> ValidationResult:
"""Example of check for developing ERC scripts.
Args:
project_data: Access to project data like nets, components, and pins.
Returns:
ValidationResult: Contains the violations identified by the function.
"""
print(f"Sample template check started: components={len(project_data.components)}")
validation_result = ValidationResult()
if project_data.components:
validation_result.add_violation(
"Example validation violation (template example)",
project_data.components[0],
)
else:
print("No components found, so the sample violation was skipped")
return validation_result
def onExecute(context: ExecutionContext, input_parameters: dict) -> ValidationResult:
"""Template entrypoint to start developing custom scripts.
Args:
context: Connection execution context for Altium 365.
input_parameters: Script input parameters used by load_project_data.
Returns:
ValidationResult: Contains the violations recognized by the script.
"""
print("Fetching design data")
project_data = load_project_data(context, input_parameters)
validation_result = _sample_erc_check(project_data)
return validation_result
Understand the Building Blocks
onExecute
This is the required entrypoint.
contextis provided by the platform and is used when the script loads project data.input_parameterscontains the project information needed to load the design data.- the function must return
ValidationResult
If your script does not expose onExecute, or returns the wrong type, it will not behave as a valid custom ERC check.
load_project_data
load_project_data(context, input_parameters) is the standard way to fetch project information before running your rule logic.
It returns a ProjectData object, which gives access to the design model used by your script.
ValidationResult
Use ValidationResult to accumulate rule violations.
The typical pattern is:
result = ValidationResult()
result.add_violation("Description of the issue", related_object)
return result
The related object should be a supported design object such as a component, net or pin.
Main APIs to Learn First
When writing custom ERC checks, the two most important API areas are design_data and utils.
design_data
The design_data module defines the project model your script works with. You will usually access these types through altium_api.
Start with these concepts:
ProjectData: root object for the loaded designComponent: logical schematic component, with designator, comment, description, parameters, and pinsNet: electrical connection with a name and connected itemsPin: pin-level access, including connected net and owning componentParameter: name/value parameter attached to a design object
Typical examples:
for component in project_data.components:
print(component.designator, component.comment)
for net in project_data.nets:
print(net.name)
Use Altium API as the main reference for ProjectData and related design objects.
utils.py
The utils module contains helper functions and constants that are useful when building rules. These helpers reduce boilerplate and keep checks focused on validation logic instead of string parsing or component classification.
Examples of what utils can help with:
- classify a component by function
- determine whether a net is power, ground, chassis, or USB
- read and parse parameter values
- infer capacitance or voltage-related values from design metadata
Example:
from altium_api import utils
def find_ground_nets(project_data: ProjectData) -> list[str]:
return [net.name for net in project_data.nets if utils.is_ground_net(net)]
Use Utilities when you need reusable helpers before implementing custom parsing or matching logic yourself.
A Practical Development Flow
The simplest way to build a custom ERC rule is to start small and iterate:
- Copy the minimal template.
- Load the project with
load_project_data. - Pick one narrow rule, for example checking a parameter, net name, or component classification.
- Add violations with a clear message and the design object that caused the issue.
- Expand the script once the first rule produces the expected output.
Example of a more realistic validation loop:
from altium import ExecutionContext
from altium_api import load_project_data, ValidationResult, ProjectData, utils
def check_missing_voltage(project_data: ProjectData) -> ValidationResult:
result = ValidationResult()
for component in project_data.components:
if utils.classify_component(component) == utils.ComponentClassification.IC:
voltage = utils.get_param_value(component, "Voltage")
if not voltage:
result.add_violation(
f"Missing Voltage parameter on {component.designator}",
component,
)
return result
def onExecute(context: ExecutionContext, input_parameters: dict) -> ValidationResult:
project_data = load_project_data(context, input_parameters)
return check_missing_voltage(project_data)
Good Practices for Customer Scripts
- Keep
onExecutesmall and move rule logic into helper functions. - Start with one rule per function so behavior stays easy to test and review.
- Use
print()for quick debugging output in the Console tab while developing. - Prefer helper functions from
utilsbefore adding custom heuristics. - Attach each violation to the most relevant design object so the result is actionable.
- Return an empty
ValidationResultwhen no violations are found.
What to Read Next
Once the template is clear, continue with these pages:
- Altium API: public API surface, including
ProjectData,Component,Net, andload_project_data - Utilities: helper functions and constants for common ERC patterns
- Checks API: reference for
ValidationResult - Documentation Home: docs landing page
These references are intended to be used alongside this getting-started guide: start here for the workflow, then use the API pages while implementing real checks.
🔧


