Download this example

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


Import Ports#

This example shows how to import operations. In this example, we are going to

  • Download an example board

  • Create a configuration file

    • Add a cutout operation

  • Import the configuration file

Import the required packages#

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

from ansys.aedt.core.examples.downloads import download_file

from pyedb import Edb

AEDT_VERSION = "2025.2"
NG_MODE = False

Download the example PCB data.

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

Load example layout and place ports#

[3]:
edbapp = Edb(file_edb, edbversion=AEDT_VERSION)
ports = [
    {
        "name": "Port_U1_P",
        "reference_designator": "U1",
        "positive_terminal": {
            "net": "PCIe_Gen4_TX3_CAP_P"
        },
        "negative_terminal": {
            "net": "GND"
        },
        "type": "circuit"
    },
    {
        "name": "Port_U1_N",
        "reference_designator": "U1",
        "positive_terminal": {
            "net": "PCIe_Gen4_TX3_CAP_N"
        },
        "negative_terminal": {
            "net": "GND"
        },
        "type": "circuit"
    },
    {
        "name": "Port_X1_P",
        "reference_designator": "X1",
        "positive_terminal": {
            "net": "PCIe_Gen4_TX3_P"
        },
        "negative_terminal": {
            "net": "GND"
        },
        "type": "circuit"
    },
    {
        "name": "Port_X1_N",
        "reference_designator": "X1",
        "positive_terminal": {
            "net": "PCIe_Gen4_TX3_N"
        },
        "negative_terminal": {
            "net": "GND"
        },
        "type": "circuit"
    }
]
cfg_1 = {"ports": ports}
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:42.551031
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.4321 seconds.
PyEDB INFO: EDB initialization completed in 7.4955 seconds.
[4]:
edbapp.configuration.load(cfg_1)
edbapp.configuration.run()
edbapp.save()
edb_path = edbapp.edbpath
edbapp.close()
PyEDB INFO: Updating boundaries finished. Time lapse 0:00:00.009916
PyEDB INFO: Updating nets finished. Time lapse 0:00:00
PyEDB INFO: Updating components finished. Time lapse 0:00:00
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.541310
PyEDB INFO: Placing ports finished. Time lapse 0:00:01.258822
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Applying operations finished. Time lapse 0:00:00
PyEDB INFO: Save Edb file completed in 0.1269 seconds.
PyEDB INFO: Close Edb file completed in 0.0795 seconds.
[4]:
True

Cutout by nets#

Keywords

  • reference_list. List of reference nets.

  • Extent_type. Supported types are Conforming, ConvexHull, and Bounding.

  • signal_list. List of signal nets to keep.

  • expansion_size. Expansion size ratio in meters. The default is 0.002.

  • use_round_corner. Whether to use round corners. Defaults to False.

  • number_of_threads. Number of threads to use. Defaults to 4.

  • extent_defeature. Simplifies geometry before applying cutout to aid meshing. Only applies to Conforming bounding box. Defaults to 0 (disabled).

  • remove_single_pin_components. Removes all single-pin RLCs after cutout. Defaults to False.

  • custom_extent. List of points defining the custom cutout shape. Overrides the extent_type setting.

  • custom_extent_units. Units of the custom extent points. Defaults to "mm". Only valid if custom_extent is provided.

  • include_partial_instances. Includes padstacks with bounding boxes intersecting the custom shape. May slow down export. Only valid with custom_extent and use_pyaedt_cutout.

  • keep_voids. Whether to keep voids intersecting the cutout polygon. Defaults to True. Valid only if custom_extent is provided.

  • check_terminals. Expands extent to include reference terminals of components with associated models.

  • include_pingroups. Includes terminals of pingroups. Requires check_terminals to be True.

  • expansion_factor. Computes the maximum between dielectric thickness and trace width (for nets with ports) multiplied by this factor. Defaults to 0 (disabled). Works only with use_pyaedt_cutout.

  • maximum_iterations. Maximum number of iterations allowed for cutout search. Defaults to 10.

  • preserve_components_with_model. Preserves all pins of components with associated models (Spice or NPort). Only applicable for PyAEDT cutouts (excluding point list).

  • simple_pad_check. Uses pad center for intersection detection instead of bounding box. Defaults to True. Bounding box method is slower and disables multithreading.

  • keep_lines_as_path. Keeps lines as Path instead of converting to PolygonData. Only works in Electronics Desktop (3D Layout). May cause issues in SiWave. Defaults to False.

  • include_voids_in_extents. Includes voids in the computed extent (for Conforming only). May affect performance. Defaults to False.

[5]:
cutout = {
    "reference_list": ["GND"],
    "extent_type": "ConvexHull",
    "signal_list": [
        "PCIe_Gen4_TX3_CAP_P",
        "PCIe_Gen4_TX3_CAP_N",
        "PCIe_Gen4_TX3_P",
        "PCIe_Gen4_TX3_N"
    ]
}
operations = {"cutout": cutout}
cfg = {"operations": operations}

Write configuration into as json file

[6]:
file_json = Path(temp_folder.name) / "cutout_1.json"
with open(file_json, "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)
[operations.cutout]
reference_list = [ "GND",]
extent_type = "ConvexHull"
signal_list = [ "PCIe_Gen4_TX3_CAP_P", "PCIe_Gen4_TX3_CAP_N", "PCIe_Gen4_TX3_P", "PCIe_Gen4_TX3_N",]

Apply cutout

[8]:
edbapp = Edb(edb_path, edbversion=AEDT_VERSION)
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
edbapp.nets.plot()
edbapp.close()
PyEDB INFO: Star initializing Edb 03:52:52.195804
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)]
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: 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 0.3979 seconds.
PyEDB INFO: EDB initialization completed in 0.3979 seconds.
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
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.297658
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Cutout Multithread started.
PyEDB INFO: Net clean up Elapsed time: 0m 1sec
PyEDB INFO: Extent Creation Elapsed time: 0m 0sec
PyEDB INFO: 1982 Padstack Instances deleted. Elapsed time: 0m 1sec
PyEDB INFO: 443 Primitives deleted. Elapsed time: 0m 3sec
PyEDB INFO: 984 components deleted
PyEDB INFO: Cutout completed. Elapsed time: 0m 5sec
PyEDB INFO: Applying operations finished. Time lapse 0:00:05.097051
../../../_images/examples_edb_use_configuration_import_operations_16_3.png
PyEDB INFO: Plot Generation time 0.918
PyEDB INFO: Close Edb file completed in 0.0994 seconds.
[8]:
True

Cutout with auto net identification#

Keywords

  • auto_identify_nets. Identify nets connected to ports

    • enabled. Resistance threshold. Resistor with value below this threshold is considered as short circuit

    • resistor_below. Resistance threshold. Resistor with value below this threshold is considered as short circuit

    • inductor_below. Inductor threshold. Inductor with value below this threshold is considered as short circuit

    • capacitor_above. Capacitor threshold. Capacitor with value below this threshold is considered as short circuit

[9]:
cutout = {
    "auto_identify_nets": {
            "enabled": True,
            "resistor_below": 100,
            "inductor_below": 1,
            "capacitor_above": 1
        },
    "reference_list": ["GND"],
    "extent_type": "ConvexHull"
}
operations = {"cutout": cutout}
cfg = {"operations": operations}

Write configuration into as json file

[10]:
file_json = Path(temp_folder.name) / "cutout_2.json"
with open(file_json, "w") as f:
    json.dump(cfg, f, indent=4, ensure_ascii=False)

Equivalent toml file looks like below

[11]:
toml_string = toml.dumps(cfg)
print(toml_string)
[operations.cutout]
reference_list = [ "GND",]
extent_type = "ConvexHull"

[operations.cutout.auto_identify_nets]
enabled = true
resistor_below = 100
inductor_below = 1
capacitor_above = 1

Apply cutout

[12]:
edbapp = Edb(edb_path, edbversion=AEDT_VERSION)
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
edbapp.nets.plot()
edbapp.close()
PyEDB INFO: Star initializing Edb 03:52:59.150331
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 0.3813 seconds.
PyEDB INFO: EDB initialization completed in 0.3833 seconds.
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
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.287039
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Cutout Multithread started.
PyEDB INFO: Net clean up Elapsed time: 0m 1sec
PyEDB INFO: Extent Creation Elapsed time: 0m 0sec
PyEDB INFO: 1982 Padstack Instances deleted. Elapsed time: 0m 1sec
PyEDB INFO: 443 Primitives deleted. Elapsed time: 0m 3sec
PyEDB INFO: 984 components deleted
PyEDB INFO: Cutout completed. Elapsed time: 0m 5sec
PyEDB INFO: Applying operations finished. Time lapse 0:00:05.996116
../../../_images/examples_edb_use_configuration_import_operations_25_1.png
PyEDB INFO: Plot Generation time 0.859
PyEDB INFO: Close Edb file completed in 0.0998 seconds.
[12]:
True

Download this example

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