Download this example
Download this example as a Jupyter Notebook or as a Python script.
Import Padstack Definitions#
This example shows how to import padstack definitions. This includes
Download an example board
Create a config file with hole information
Create a config file with pad and anti-pad information
Perform imports and define constants#
Perform required imports.
[1]:
import json
import tempfile
import time
from pathlib import Path
import pandas as pd
import toml
from ansys.aedt.core.examples.downloads import download_file
from IPython.display import display
from pyedb import Edb
Define constants.
[2]:
AEDT_VERSION = "2025.2"
Download the example PCB data.
[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
file_edb = download_file(source="edb/ANSYS-HSD_V1.aedb", local_path=temp_folder.name)
Load example layout.#
[4]:
edbapp = Edb(edbpath=file_edb, version=AEDT_VERSION)
PyEDB INFO: Star initializing Edb 05:33:00.638663
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.0495 seconds.
PyEDB INFO: EDB initialization completed in 9.1283 seconds.
Create a config file with hole information#
Keywords
name. Name of the padstack definition.
hole_plating_thickness. Hole plating thickness.
hole_range. Supported types are ‘through’, ‘begin_on_upper_pad’, ‘end_on_lower_pad’, ‘upper_pad_to_lower_pad’.
hole_parameters.
shape. Supported types are ‘circle’, ‘square’, ‘rectangle’.
Other parameters are shape dependent.
When shape is ‘circle’, supported parameter si ‘diameter’.
When shape is ‘square’, supported parameter is ‘size’.
When shape is ‘rectangle’, supported parameters are ‘x_size’, ‘y_size’.
[5]:
cfg = dict()
cfg["padstacks"] = {}
cfg["padstacks"]["definitions"] = [
{
"name": "v35h15",
"hole_plating_thickness": "25um",
"material": "copper",
"hole_range": "through",
"hole_parameters": {
"shape": "circle",
"diameter": "0.15mm",
},
}
]
[6]:
df = pd.DataFrame(data=cfg["padstacks"]["definitions"])
display(df)
| name | hole_plating_thickness | material | hole_range | hole_parameters | |
|---|---|---|---|---|---|
| 0 | v35h15 | 25um | copper | through | {'shape': 'circle', 'diameter': '0.15mm'} |
[7]:
cfg_file_path = Path(temp_folder.name) / "cfg.json"
with open(cfg_file_path, "w") as f:
json.dump(cfg, f, indent=4, ensure_ascii=False)
Load config file
[8]:
edbapp.configuration.load(cfg_file_path, apply_file=True)
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: Updating stackup finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.0475 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: Applying operations completed in 0.0000 seconds.
PyEDB INFO: Applying setups completed in 0.0000 seconds.
[8]:
<pyedb.configuration.cfg_data.CfgData at 0x26614db23b0>
Create a config file with pad information#
Keywords
name. Name of the padstack definition.
pad_parameters.
regular_pad. List of pad definition per layer.
layer_name. Name of the layer.
shape. Supported types are ‘circle’, ‘square’, ‘rectangle’, ‘oval’, ‘bullet’.
Other parameters are shape dependent.
When shape is ‘circle’, supported parameter si ‘diameter’.
When shape is ‘square’, supported parameter is ‘size’.
When shape is ‘rectangle’, supported parameters are ‘x_size’, ‘y_size’.
When shape is ‘oval’, supported parameters are ‘x_size’, ‘y_size’, ‘corner_radius’.
When shape is ‘bullet’, supported parameters are ‘x_size’, ‘y_size’, ‘corner_radius’.
[9]:
cfg = dict()
cfg["padstacks"] = {}
cfg["padstacks"]["definitions"] = [
{
"name": "v35h15",
"pad_parameters": {
"regular_pad": [
{
"layer_name": "1_Top",
"shape": "circle",
"offset_x": "0.1mm",
"offset_y": "0.1mm",
"rotation": "0",
"diameter": "0.5mm",
},
{
"layer_name": "Inner1(GND1)",
"shape": "square",
"offset_x": "0.1mm",
"offset_y": "0.1mm",
"rotation": "45deg",
"size": "0.5mm",
},
],
"anti_pad": [{"layer_name": "1_Top", "shape": "circle", "diameter": "1mm"}],
},
}
]
[10]:
cfg_file_path = Path(temp_folder.name) / "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
[11]:
toml_string = toml.dumps(cfg)
print(toml_string)
[padstacks]
[[padstacks.definitions]]
name = "v35h15"
[padstacks.definitions.pad_parameters]
[[padstacks.definitions.pad_parameters.regular_pad]]
layer_name = "1_Top"
shape = "circle"
offset_x = "0.1mm"
offset_y = "0.1mm"
rotation = "0"
diameter = "0.5mm"
[[padstacks.definitions.pad_parameters.regular_pad]]
layer_name = "Inner1(GND1)"
shape = "square"
offset_x = "0.1mm"
offset_y = "0.1mm"
rotation = "45deg"
size = "0.5mm"
[[padstacks.definitions.pad_parameters.anti_pad]]
layer_name = "1_Top"
shape = "circle"
diameter = "1mm"
Load config file
[12]:
edbapp.configuration.load(cfg_file_path, apply_file=True)
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: Updating stackup finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.0315 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: Applying operations completed in 0.0000 seconds.
PyEDB INFO: Applying setups completed in 0.0000 seconds.
[12]:
<pyedb.configuration.cfg_data.CfgData at 0x266175b88e0>
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.
[13]:
edbapp.save()
edbapp.close()
PyEDB INFO: Save Edb file completed in 0.1109 seconds.
PyEDB INFO: Close Edb file completed in 0.0791 seconds.
[13]:
True
[14]:
# 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.
[15]:
temp_folder.cleanup()
Download this example
Download this example as a Jupyter Notebook or as a Python script.