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 tempfile
import time
from pathlib import Path

import toml
from ansys.aedt.core.examples.downloads import download_file
from pyedb import Edb

AEDT_VERSION = "2026.1"
NG_MODE = False

Download the example PCB data.

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

Load example layout and place ports#

[3]:
edbapp = Edb(edbpath=file_edb, version=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\generic\design_types.py:375: UserWarning: You are using PyEDB with grpc, which is currently in beta. Some feature might be missing or not working as expected. Please report any issue you find to the PyEDB team.
  warnings.warn(GRPC_BETA_WARNING, UserWarning)
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Using PyEDB with gRPC as Beta until ANSYS 2027R1 official release.
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Grpc session started
PyEDB INFO: Grpc session started: pid=6020
PyEDB INFO: RPC session acquired (open databases: 1)
PyEDB INFO: Database ANSYS-HSD_V1.aedb Opened in 2026.1
PyEDB INFO: Cell main Opened
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: Builder was initialized.
PyEDB INFO: EDB initialized.
[4]:
edbapp.configuration.load(cfg_1)
edbapp.configuration.run()
edbapp.save()
edb_path = edbapp.edbpath
edbapp.close()
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: Applying materials finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.1745 seconds.
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
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\configuration\cfg_ports_sources.py:564: FutureWarning: Call to deprecated function create_pin_group. use edb.components.create_pin_group method instead
  name, temp = self._pedb.siwave.create_pin_group(reference_designator, pin_names, pg_name)
PyEDB INFO: Placing ports finished. Time lapse 0:00:12.152233
PyEDB INFO: Placing terminals completed in 0.0000 seconds.
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Applying operations completed in 0.0000 seconds.
PyEDB INFO: Applying setups completed in 0.0000 seconds.
PyEDB INFO: RPC session released (open databases: 0)
[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(edbpath=edb_path, version=AEDT_VERSION)
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
edbapp.nets.plot()
edbapp.close()
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Using PyEDB with gRPC as Beta until ANSYS 2027R1 official release.
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Grpc session started
PyEDB INFO: Grpc session started: pid=5884
PyEDB INFO: RPC session acquired (open databases: 1)
PyEDB INFO: Database ANSYS-HSD_V1.aedb Opened in 2026.1
PyEDB INFO: Cell main Opened
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: Builder was initialized.
PyEDB INFO: EDB initialized.
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: Applying materials finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.1684 seconds.
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
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing terminals completed in 0.0000 seconds.
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: -----------------------------------------
PyEDB INFO: Trying cutout with 2.0mm expansion size
PyEDB INFO: -----------------------------------------
PyEDB INFO: GRPC cut-out started
PyEDB INFO: [READ] Data collection finished in 4.951 s
PyEDB INFO: Nets:348, padstack_instances:5699, primitives:2107, components:509
PyEDB INFO: [EXTENT] Polygon created in 0.685 s
PyEDB INFO: [COMPUTE] Decision lists ready in 20.083 s
PyEDB INFO: Starting single write-pass
PyEDB INFO: Deleting 343 nets
PyEDB INFO: 5621 pad-stack instances deleted in 0.159 s
PyEDB INFO: 3833 primitives deleted in 0.095 s
PyEDB INFO: 6 primitives created in 0.207 s
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\workflows\utilities\cutout.py:778: FutureWarning: Accessing deprecated property numpins. use num_pins property instead
  components_to_delete = [comp for comp in all_components if comp.numpins == 0]
PyEDB INFO: 492 components deleted in 0.713 s
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: [WRITE] All writes finished in 3.432 s
PyEDB INFO: GRPC-safe cut-out completed Elapsed time: 0m 29sec
PyEDB INFO: Cutout completed in 1 iterations with expansion size of 2.0mm Elapsed time: 0m 29sec
PyEDB INFO: Applying operations completed in 29.4480 seconds.
PyEDB INFO: Applying setups completed in 0.0000 seconds.
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\common\nets.py:343: FutureWarning: Accessing deprecated property primitives_by_layer. use layout.primitives_by_layer property instead.
  prims_by_layers_dict = {i: j for i, j in self._pedb.modeler.primitives_by_layer.items()}
../../../_images/examples_edb_use_configuration_import_operations_16_4.png
PyEDB INFO: Plot Generation time 1.859
PyEDB INFO: RPC session released (open databases: 0)
[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(edbpath=edb_path, version=AEDT_VERSION)
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
edbapp.nets.plot()
edbapp.close()
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Using PyEDB with gRPC as Beta until ANSYS 2027R1 official release.
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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\generic\design_types.py:375: UserWarning: You are using PyEDB with grpc, which is currently in beta. Some feature might be missing or not working as expected. Please report any issue you find to the PyEDB team.
  warnings.warn(GRPC_BETA_WARNING, UserWarning)
PyEDB INFO: Grpc session started
PyEDB INFO: Grpc session started: pid=4624
PyEDB INFO: RPC session acquired (open databases: 1)
PyEDB INFO: Database ANSYS-HSD_V1.aedb Opened in 2026.1
PyEDB INFO: Cell main Opened
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: Builder was initialized.
PyEDB INFO: EDB initialized.
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: Applying materials finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.1835 seconds.
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
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing terminals completed in 0.0000 seconds.
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\configuration\configuration.py:847: FutureWarning: Call to deprecated function generate_extended_nets. use edb.extended_nets.generate_extended_nets method instead
  self._pedb.nets.generate_extended_nets(
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\generic\constants.py:250: UserWarning: Unknown units: 'F    '
  warnings.warn("Unknown units: '{}'".format(input_units))
PyEDB INFO: -----------------------------------------
PyEDB INFO: Trying cutout with 2.0mm expansion size
PyEDB INFO: -----------------------------------------
PyEDB INFO: GRPC cut-out started
PyEDB INFO: [READ] Data collection finished in 0.038 s
PyEDB INFO: Nets:5, padstack_instances:78, primitives:13, components:17
PyEDB INFO: [EXTENT] Polygon created in 0.041 s
PyEDB INFO: [COMPUTE] Decision lists ready in 0.634 s
PyEDB INFO: Starting single write-pass
PyEDB INFO: Deleting 0 nets
PyEDB INFO: 0 pad-stack instances deleted in 0.000 s
PyEDB INFO: 35 primitives deleted in 0.016 s
PyEDB INFO: 6 primitives created in 0.048 s
PyEDB INFO: 0 components deleted in 0.016 s
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: [WRITE] All writes finished in 0.100 s
PyEDB INFO: GRPC-safe cut-out completed Elapsed time: 0m 1sec
PyEDB INFO: Cutout completed in 1 iterations with expansion size of 2.0mm Elapsed time: 0m 1sec
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\workflows\utilities\cutout.py:778: FutureWarning: Accessing deprecated property numpins. use num_pins property instead
  components_to_delete = [comp for comp in all_components if comp.numpins == 0]
PyEDB INFO: Applying operations completed in 1.3811 seconds.
PyEDB INFO: Applying setups completed in 0.0000 seconds.
../../../_images/examples_edb_use_configuration_import_operations_25_7.png
PyEDB INFO: Plot Generation time 1.809
PyEDB INFO: RPC session released (open databases: 0)
[12]:
True
[13]:
# Wait 3 seconds before cleaning the temporary directory.
time.sleep(3)

Clean up#

All project files are saved in the folder temp_folder.name. If you’ve run this example as a Jupyter notebook, you can retrieve those project files. The following cell removes all temporary files, including the project folder.

[14]:
temp_folder.cleanup()

Download this example

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