Download this example

Download this example as a Jupyter Notebook or as a Python script.


Import Component Definitions#

This example shows how to import component definitions. It includes

  • Download an example board

  • Create a config file with component RLC and solder ball information

  • Apply the config file to the example board

Perform imports and define constants#

Perform required imports.

[1]:
import json
import toml
from pathlib import Path
import tempfile

from IPython.display import display
from ansys.aedt.core.examples.downloads import download_file
import pandas as pd
from pyedb import Edb

Define constants.

[2]:
AEDT_VERSION = "2025.2"

Download the example PCB data.

[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys").name
file_edb = download_file(source="edb/ANSYS-HSD_V1.aedb", local_path=temp_folder)

Load example layout.#

[4]:
edbapp = Edb(file_edb, edbversion=AEDT_VERSION)
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:33: UserWarning: Argument `edbversion` is deprecated for method `Edb`; use `version` instead.
  warnings.warn(
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\generic\design_types.py:327: UserWarning: Your ANSYS AEDT version is eligible to gRPC version.You might consider switching to that version for better user experience.For more information please check this link: https://edb.docs.pyansys.com/version/dev/grpc_api/index.html
  warnings.warn(GRPC_GENERAL_WARNING, UserWarning)
PyEDB INFO: Star initializing Edb 03:52:03.830747
PyEDB INFO: Edb version 2025.2
PyEDB INFO: Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
PyEDB INFO: legacy v0.56.0
PyEDB INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyEDB INFO: Database ANSYS-HSD_V1.aedb Opened in 2025.2
PyEDB INFO: Cell main Opened
PyEDB INFO: Builder was initialized.
PyEDB INFO: open_edb completed in 7.4527 seconds.
PyEDB INFO: EDB initialization completed in 7.5166 seconds.

Create a config file with component information#

Keywords

  • reference_designator. Reference designator of the component.

  • part_type. Part type of the component. Supported types are ‘resistor’, ‘inductor’, ‘capacitor’, ‘ic’, ‘io’, ‘other’.

  • enabled. Only available for RLC components.

  • solder_ball_properties.

    • shape. Supported types are ‘cylinder’, ‘spheroid’, ‘none’.

    • diameter.

    • mid_diameter.

    • height.

    • material.

  • port_properties.

    • reference_offset.

    • reference_size_auto.

    • reference_size_x.

    • reference_size_y.

  • pin_pair_model. RLC network. Multiple pin pairs are supported.

    • first_pin. First pin of the pin pair.

    • second_pin. Second pin of the pin pair.

    • is_parallel.

    • resistance.

    • resistance_enabled.

    • inductance.

    • inductance_enabled.

    • capacitance.

    • capacitance_enabled.

[5]:
cfg = dict()
cfg["components"] = [
    {
        "reference_designator": "U1",
        "part_type": "io",
        "solder_ball_properties": {
            "shape": "spheroid",
            "diameter": "244um",
            "mid_diameter": "400um",
            "height": "300um",
            "material": "air",
        },
        "port_properties": {
            "reference_offset": "0.1mm",
            "reference_size_auto": True,
            "reference_size_x": 0,
            "reference_size_y": 0,
        },
    },
    {
        "reference_designator": "C375",
        "enabled": False,
        "pin_pair_model": [
            {
                "first_pin": "1",
                "second_pin": "2",
                "is_parallel": False,
                "resistance": "10ohm",
                "resistance_enabled": True,
                "inductance": "1nH",
                "inductance_enabled": False,
                "capacitance": "10nF",
                "capacitance_enabled": True,
            }
        ],
    },
]
[6]:
cfg_file_path = Path(temp_folder) / "cfg.json"
with open(cfg_file_path, "w") as f:
    json.dump(cfg, f, indent=4, ensure_ascii=False)

Equivalent toml file looks like below

[7]:
toml_string = toml.dumps(cfg)
print(toml_string)
[[components]]
reference_designator = "U1"
part_type = "io"

[components.solder_ball_properties]
shape = "spheroid"
diameter = "244um"
mid_diameter = "400um"
height = "300um"
material = "air"
[components.port_properties]
reference_offset = "0.1mm"
reference_size_auto = true
reference_size_x = 0
reference_size_y = 0
[[components]]
reference_designator = "C375"
enabled = false
[[components.pin_pair_model]]
first_pin = "1"
second_pin = "2"
is_parallel = false
resistance = "10ohm"
resistance_enabled = true
inductance = "1nH"
inductance_enabled = false
capacitance = "10nF"
capacitance_enabled = true



Apply config file#

[8]:
edbapp.configuration.load(cfg_file_path, apply_file=True)
PyEDB INFO: Updating boundaries finished. Time lapse 0:00:00
PyEDB INFO: Updating nets finished. Time lapse 0:00:00
PyEDB INFO: Updating components finished. Time lapse 0:00:00.035549
PyEDB INFO: Creating pin groups finished. Time lapse 0:00:00
PyEDB INFO: Placing sources finished. Time lapse 0:00:00
PyEDB INFO: Creating setups finished. Time lapse 0:00:00
PyEDB INFO: Applying materials finished. Time lapse 0:00:00
PyEDB INFO: Updating stackup finished. Time lapse 0:00:00
PyEDB INFO: Applying padstacks finished. Time lapse 0:00:00
PyEDB INFO: Applying S-parameters finished. Time lapse 0:00:00
PyEDB INFO: Applying package definitions finished. Time lapse 0:00:00
PyEDB INFO: Applying modeler finished. Time lapse 0:00:00.569059
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Applying operations finished. Time lapse 0:00:00
[8]:
<pyedb.configuration.cfg_data.CfgData at 0x14094bfa8c0>

Save and close Edb

The temporary folder will be deleted once the execution of this script is finished. Replace edbapp.save() with edbapp.save_as(“C:/example.aedb”) to keep the example project.

[9]:
edbapp.save()
edbapp.close()
PyEDB INFO: Save Edb file completed in 0.1270 seconds.
PyEDB INFO: Close Edb file completed in 0.0641 seconds.
[9]:
True

Download this example

Download this example as a Jupyter Notebook or as a Python script.