{ "cells": [ { "cell_type": "markdown", "id": "c01fa7c4", "metadata": {}, "source": [ "# Import Padstack Definitions\n", "This example shows how to import padstack definitions. This includes\n", "\n", "- Download an example board\n", "- Create a config file with hole information\n", "- Create a config file with pad and anti-pad information" ] }, { "cell_type": "markdown", "id": "d13484bf", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "a12668e6", "metadata": {}, "outputs": [], "source": [ "import json\n", "import toml\n", "from pathlib import Path\n", "import tempfile\n", "\n", "from IPython.display import display\n", "from ansys.aedt.core.examples.downloads import download_file\n", "import pandas as pd\n", "\n", "from pyedb import Edb" ] }, { "cell_type": "markdown", "id": "f7c13f69", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "0d14419a", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"" ] }, { "cell_type": "markdown", "id": "47b4dd83", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "d81b4e27", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\").name\n", "file_edb = download_file(source=\"edb/ANSYS-HSD_V1.aedb\", local_path=temp_folder)" ] }, { "cell_type": "markdown", "id": "f4470b14", "metadata": {}, "source": [ "## Load example layout." ] }, { "cell_type": "code", "execution_count": null, "id": "eec19e70", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "b7a0fa43", "metadata": {}, "source": [ "## Create a config file with hole information" ] }, { "cell_type": "markdown", "id": "82448eb6", "metadata": {}, "source": [ "Keywords\n", "\n", "- **name**. Name of the padstack definition.\n", "- **hole_plating_thickness**. Hole plating thickness.\n", "- **hole_range**. Supported types are 'through', 'begin_on_upper_pad', 'end_on_lower_pad', 'upper_pad_to_lower_pad'.\n", "- **hole_parameters**.\n", " - **shape**. Supported types are 'circle', 'square', 'rectangle'.\n", " - Other parameters are shape dependent.\n", " - When shape is 'circle', supported parameter si 'diameter'.\n", " - When shape is 'square', supported parameter is 'size'.\n", " - When shape is 'rectangle', supported parameters are 'x_size', 'y_size'." ] }, { "cell_type": "code", "execution_count": null, "id": "9692eaea", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"padstacks\"] = {}\n", "cfg[\"padstacks\"][\"definitions\"] = [\n", " {\n", " \"name\": \"v35h15\",\n", " \"hole_plating_thickness\": \"25um\",\n", " \"material\": \"copper\",\n", " \"hole_range\": \"through\",\n", " \"hole_parameters\": {\n", " \"shape\": \"circle\",\n", " \"diameter\": \"0.15mm\",\n", " },\n", " }\n", "]" ] }, { "cell_type": "code", "execution_count": null, "id": "f22cefbb", "metadata": {}, "outputs": [], "source": [ "df = pd.DataFrame(data=cfg[\"padstacks\"][\"definitions\"])\n", "display(df)" ] }, { "cell_type": "code", "execution_count": null, "id": "6f12646e", "metadata": {}, "outputs": [], "source": [ "cfg_file_path = Path(temp_folder) / \"cfg.json\"\n", "with open(cfg_file_path, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "862bffb8", "metadata": {}, "source": [ "Load config file" ] }, { "cell_type": "code", "execution_count": null, "id": "11598cee", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(cfg_file_path, apply_file=True)" ] }, { "cell_type": "markdown", "id": "c3522c2f", "metadata": {}, "source": [ "## Create a config file with pad information" ] }, { "cell_type": "markdown", "id": "4fa7ffda", "metadata": {}, "source": [ "Keywords\n", "\n", "- **name**. Name of the padstack definition.\n", "- **pad_parameters**.\n", " - **regular_pad**. List of pad definition per layer.\n", " - **layer_name**. Name of the layer.\n", " - **shape**. Supported types are 'circle', 'square', 'rectangle', 'oval', 'bullet'.\n", " - Other parameters are shape dependent.\n", " - When shape is 'circle', supported parameter si 'diameter'.\n", " - When shape is 'square', supported parameter is 'size'.\n", " - When shape is 'rectangle', supported parameters are 'x_size', 'y_size'.\n", " - When shape is 'oval', supported parameters are 'x_size', 'y_size', 'corner_radius'.\n", " - When shape is 'bullet', supported parameters are 'x_size', 'y_size', 'corner_radius'." ] }, { "cell_type": "code", "execution_count": null, "id": "b2912cf3", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"padstacks\"] = {}\n", "cfg[\"padstacks\"][\"definitions\"] = [\n", " {\n", " \"name\": \"v35h15\",\n", " \"pad_parameters\": {\n", " \"regular_pad\": [\n", " {\n", " \"layer_name\": \"1_Top\",\n", " \"shape\": \"circle\",\n", " \"offset_x\": \"0.1mm\",\n", " \"offset_y\": \"0.1mm\",\n", " \"rotation\": \"0\",\n", " \"diameter\": \"0.5mm\",\n", " },\n", " {\n", " \"layer_name\": \"Inner1(GND1)\",\n", " \"shape\": \"square\",\n", " \"offset_x\": \"0.1mm\",\n", " \"offset_y\": \"0.1mm\",\n", " \"rotation\": \"45deg\",\n", " \"size\": \"0.5mm\",\n", " },\n", " ],\n", " \"anti_pad\": [{\"layer_name\": \"1_Top\", \"shape\": \"circle\", \"diameter\": \"1mm\"}],\n", " },\n", " }\n", "]" ] }, { "cell_type": "code", "execution_count": null, "id": "3c3b5975", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "cfg_file_path = Path(temp_folder) / \"cfg.json\"\n", "with open(cfg_file_path, \"w\") as f:\n", " json.dump(cfg, f, indent=4, ensure_ascii=False)" ] }, { "cell_type": "markdown", "id": "3f423161", "metadata": {}, "source": [ "Equivalent toml file looks like below " ] }, { "cell_type": "code", "execution_count": null, "id": "50f629c5", "metadata": { "lines_to_next_cell": 2 }, "outputs": [], "source": [ "toml_string = toml.dumps(cfg)\n", "print(toml_string)" ] }, { "cell_type": "markdown", "id": "784e279b", "metadata": {}, "source": [ "Load config file" ] }, { "cell_type": "code", "execution_count": null, "id": "592af9eb", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(cfg_file_path, apply_file=True)" ] }, { "cell_type": "markdown", "id": "0c6f505d", "metadata": {}, "source": [ "## Save and close Edb\n", "The temporary folder will be deleted once the execution of this script is finished. Replace edbapp.save() with\n", "edbapp.save_as(\"C:/example.aedb\") to keep the example project." ] }, { "cell_type": "code", "execution_count": null, "id": "749fec32", "metadata": {}, "outputs": [], "source": [ "edbapp.save()\n", "edbapp.close()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }