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 time

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("pyaedt/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\tmp_64cvi8d.ansys\pyaedt\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, version=edb_version)
EDB version: 2025.2
PyEDB INFO: Star initializing Edb 05:24:52.511935
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.70.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 9.0987 seconds.
PyEDB INFO: EDB initialization completed in 9.1619 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_nets=signal_list,
    reference_nets=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: -----------------------------------------
PyEDB INFO: Trying cutout with (0.002)*(1000.0)mm expansion size
PyEDB INFO: -----------------------------------------
PyEDB INFO: Cutout Multithread started.
PyEDB INFO: Net clean up Elapsed time: 0m 2sec
PyEDB INFO: Extent Creation Elapsed time: 0m 0sec
PyEDB INFO: 1822 Padstack Instances deleted. Elapsed time: 0m 1sec
PyEDB INFO: 425 Primitives deleted. Elapsed time: 0m 2sec
PyEDB INFO: 928 components deleted
PyEDB INFO: Deleted 464 components
PyEDB INFO: Single Pins components deleted Elapsed time: 0m 0sec
PyEDB INFO: Cutout completed. Elapsed time: 0m 5sec
PyEDB INFO: EDB file save completed in 0.0638 seconds.
PyEDB INFO: Cutout completed in 1 iterations with expansion size of (0.002)*(1000.0)mm Elapsed time: 0m 5sec
../../../_images/examples_edb_legacy_standalone_edb_to_ipc2581_9_1.png
PyEDB INFO: Plot Generation time 1.974
[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(ipc_path=ipc2581_file_name)
print("IPC2581 File has been saved to {}".format(ipc2581_file_name))
PyEDB INFO: Translation successfully completed.
IPC2581 File has been saved to C:\Users\ansys\AppData\Local\Temp\tmp_64cvi8d.ansys\Ansys_Hsd.xml

Close EDB#

[7]:
edb.close()
PyEDB INFO: Close Edb file completed in 0.1110 seconds.
[7]:
True
[8]:
# 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.

[9]:
temp_dir.cleanup()

Download this example

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