Download this example
Download this example as a Jupyter Notebook or as a Python script.
EDB: IPC2581 export#
This example shows how you can use PyAEDT to export an IPC2581 file.
Perform required imports, which includes importing a section.
[1]:
import os
import tempfile
import pyedb
from pyedb.generic.general_methods import generate_unique_name
from pyedb.misc.downloads import download_file
Download the AEDB file and copy it in the temporary folder.#
[2]:
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
targetfile = download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name)
ipc2581_file_name = os.path.join(temp_dir.name, "Ansys_Hsd.xml")
print(targetfile)
C:\Users\ansys\AppData\Local\Temp\tmpvrovh_yt.ansys\edb/ANSYS-HSD_V1.aedb
Launch EDB#
Launch the pyedb.Edb class, using EDB 2023. > Note that length dimensions passed to EDB are in SI units.
[3]:
# Select EDB version (change it manually if needed, e.g. "2025.1")
edb_version = "2025.2"
print(f"EDB version: {edb_version}")
edb = pyedb.Edb(edbpath=targetfile, edbversion=edb_version)
EDB version: 2025.2
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:55: 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:301: 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 13:08:42.762122
INFO:Edb:Star initializing Edb 13:08:42.762122
PyEDB INFO: Edb version 2025.2
INFO:Edb:Edb version 2025.2
PyEDB INFO: Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
INFO:Edb:Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
PyEDB INFO: legacy v0.61.0
INFO:Edb:legacy v0.61.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)]
INFO:Edb: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
INFO:Edb:Database ANSYS-HSD_V1.aedb Opened in 2025.2
PyEDB INFO: Cell main Opened
INFO:Edb:Cell main Opened
PyEDB INFO: Builder was initialized.
INFO:Edb:Builder was initialized.
PyEDB INFO: open_edb completed in 9.0121 seconds.
INFO:Edb:open_edb completed in 9.0121 seconds.
PyEDB INFO: EDB initialization completed in 9.0916 seconds.
INFO:Edb:EDB initialization completed in 9.0916 seconds.
Parametrize the width of a trace.#
[4]:
edb.modeler.parametrize_trace_width("A0_N", parameter_name=generate_unique_name("Par"), variable_value="0.4321mm")
[4]:
True
Create a cutout and plot it.#
[5]:
signal_list = []
for net in edb.nets.netlist:
if "PCIe" in net:
signal_list.append(net)
power_list = ["GND"]
edb.cutout(
signal_list=signal_list,
reference_list=power_list,
extent_type="ConvexHull",
expansion_size=0.002,
use_round_corner=False,
number_of_threads=4,
remove_single_pin_components=True,
use_pyaedt_extent_computing=True,
extent_defeature=0,
)
edb.nets.plot(None, None, color_by_net=True)
PyEDB INFO: -----------------------------------------
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:55: UserWarning: Argument `signal_list` is deprecated for method `cutout`; use `signal_nets` instead.
warnings.warn(
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:55: UserWarning: Argument `reference_list` is deprecated for method `cutout`; use `reference_nets` instead.
warnings.warn(
INFO:Edb:-----------------------------------------
PyEDB INFO: Trying cutout with (0.002)*(1000.0)mm expansion size
INFO:Edb:Trying cutout with (0.002)*(1000.0)mm expansion size
PyEDB INFO: -----------------------------------------
INFO:Edb:-----------------------------------------
PyEDB INFO: Cutout Multithread started.
INFO:Edb:Cutout Multithread started.
PyEDB INFO: Net clean up Elapsed time: 0m 1sec
INFO:Edb:Net clean up Elapsed time: 0m 1sec
PyEDB INFO: Extent Creation Elapsed time: 0m 0sec
INFO:Edb:Extent Creation Elapsed time: 0m 0sec
PyEDB INFO: 1822 Padstack Instances deleted. Elapsed time: 0m 1sec
INFO:Edb:1822 Padstack Instances deleted. Elapsed time: 0m 1sec
PyEDB INFO: 425 Primitives deleted. Elapsed time: 0m 2sec
INFO:Edb:425 Primitives deleted. Elapsed time: 0m 2sec
PyEDB INFO: 928 components deleted
INFO:Edb:928 components deleted
PyEDB INFO: Deleted 464 components
INFO:Edb:Deleted 464 components
PyEDB INFO: Single Pins components deleted Elapsed time: 0m 0sec
INFO:Edb:Single Pins components deleted Elapsed time: 0m 0sec
PyEDB INFO: Cutout completed. Elapsed time: 0m 5sec
INFO:Edb:Cutout completed. Elapsed time: 0m 5sec
PyEDB INFO: EDB file save completed in 0.0693 seconds.
INFO:Edb:EDB file save completed in 0.0693 seconds.
PyEDB INFO: Cutout completed in 1 iterations with expansion size of (0.002)*(1000.0)mm Elapsed time: 0m 5sec
INFO:Edb:Cutout completed in 1 iterations with expansion size of (0.002)*(1000.0)mm Elapsed time: 0m 5sec
PyEDB INFO: Plot Generation time 2.064
INFO:Edb:Plot Generation time 2.064
[5]:
(<Figure size 6000x3000 with 1 Axes>,
<Axes: title={'center': 'Edb Top View main'}>)
Export the EDB to an IPC2581 file.#
[6]:
edb.export_to_ipc2581(ipc2581_file_name, "inch")
print("IPC2581 File has been saved to {}".format(ipc2581_file_name))
PyEDB INFO: Export IPC 2581 is starting. This operation can take a while.
INFO:Edb:Export IPC 2581 is starting. This operation can take a while.
PyEDB INFO: Parsing Layers...
INFO:Edb:Parsing Layers...
PyEDB INFO: Parsing BOM...
INFO:Edb:Parsing BOM...
PyEDB INFO: Parsing Padstack Definitions...
INFO:Edb:Parsing Padstack Definitions...
PyEDB INFO: Parsing Components...
INFO:Edb:Parsing Components...
PyEDB INFO: Parsing Logical Nets...
INFO:Edb:Parsing Logical Nets...
PyEDB INFO: Parsing Layout Primitives...
INFO:Edb:Parsing Layout Primitives...
PyEDB INFO: Parsing Drills...
INFO:Edb:Parsing Drills...
PyEDB INFO: Parsing EDB Completed!
INFO:Edb:Parsing EDB Completed!
PyEDB INFO: Export IPC 2581 completed. Elapsed time: 0m 2sec
INFO:Edb:Export IPC 2581 completed. Elapsed time: 0m 2sec
PyEDB INFO: File saved as C:\Users\ansys\AppData\Local\Temp\tmpvrovh_yt.ansys\Ansys_Hsd.xml
INFO:Edb:File saved as C:\Users\ansys\AppData\Local\Temp\tmpvrovh_yt.ansys\Ansys_Hsd.xml
IPC2581 File has been saved to C:\Users\ansys\AppData\Local\Temp\tmpvrovh_yt.ansys\Ansys_Hsd.xml
Close EDB#
[7]:
edb.close_edb()
PyEDB INFO: Close Edb file completed in 0.1192 seconds.
INFO:Edb:Close Edb file completed in 0.1192 seconds.
[7]:
True
Clean up the temporary directory#
[8]:
temp_dir.cleanup()
Download this example
Download this example as a Jupyter Notebook or as a Python script.