{ "cells": [ { "cell_type": "markdown", "id": "4fd6b0c0", "metadata": {}, "source": [ "# Import Component Definitions\n", "This example shows how to import component definitions. It includes\n", "\n", "- Download an example board\n", "- Create a config file with component RLC and solder ball information\n", "- Apply the config file to the example board" ] }, { "cell_type": "markdown", "id": "cf780657", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "96956872", "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", "from pyedb import Edb" ] }, { "cell_type": "markdown", "id": "9f6b1902", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "2aec6255", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"" ] }, { "cell_type": "markdown", "id": "0518e563", "metadata": {}, "source": [ "Download the example PCB data." ] }, { "cell_type": "code", "execution_count": null, "id": "7201b2fb", "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": "849401d8", "metadata": {}, "source": [ "## Load example layout." ] }, { "cell_type": "code", "execution_count": null, "id": "ffe882f9", "metadata": {}, "outputs": [], "source": [ "edbapp = Edb(file_edb, edbversion=AEDT_VERSION)" ] }, { "cell_type": "markdown", "id": "33902ed4", "metadata": {}, "source": [ "## Create a config file with component information" ] }, { "cell_type": "markdown", "id": "02ca1dff", "metadata": {}, "source": [ "Keywords\n", "\n", "- **reference_designator**. Reference designator of the component.\n", "- **part_type**. Part type of the component. Supported types are 'resistor', 'inductor', 'capacitor', 'ic', 'io',\n", "'other'.\n", "- **enabled**. Only available for RLC components.\n", "- **solder_ball_properties**.\n", " - **shape**. Supported types are 'cylinder', 'spheroid', 'none'.\n", " - **diameter**.\n", " - **mid_diameter**.\n", " - **height**.\n", " - **material**.\n", "- **port_properties**.\n", " - **reference_offset**.\n", " - **reference_size_auto**.\n", " - **reference_size_x**.\n", " - **reference_size_y**.\n", "- **pin_pair_model**. RLC network. Multiple pin pairs are supported.\n", " - **first_pin**. First pin of the pin pair.\n", " - **second_pin**. Second pin of the pin pair.\n", " - **is_parallel**.\n", " - **resistance**.\n", " - **resistance_enabled**.\n", " - **inductance**.\n", " - **inductance_enabled**.\n", " - **capacitance**.\n", " - **capacitance_enabled**." ] }, { "cell_type": "code", "execution_count": null, "id": "8cab50c5", "metadata": {}, "outputs": [], "source": [ "cfg = dict()\n", "cfg[\"components\"] = [\n", " {\n", " \"reference_designator\": \"U1\",\n", " \"part_type\": \"io\",\n", " \"solder_ball_properties\": {\n", " \"shape\": \"spheroid\",\n", " \"diameter\": \"244um\",\n", " \"mid_diameter\": \"400um\",\n", " \"height\": \"300um\",\n", " \"material\": \"air\",\n", " },\n", " \"port_properties\": {\n", " \"reference_offset\": \"0.1mm\",\n", " \"reference_size_auto\": True,\n", " \"reference_size_x\": 0,\n", " \"reference_size_y\": 0,\n", " },\n", " },\n", " {\n", " \"reference_designator\": \"C375\",\n", " \"enabled\": False,\n", " \"pin_pair_model\": [\n", " {\n", " \"first_pin\": \"1\",\n", " \"second_pin\": \"2\",\n", " \"is_parallel\": False,\n", " \"resistance\": \"10ohm\",\n", " \"resistance_enabled\": True,\n", " \"inductance\": \"1nH\",\n", " \"inductance_enabled\": False,\n", " \"capacitance\": \"10nF\",\n", " \"capacitance_enabled\": True,\n", " }\n", " ],\n", " },\n", "]" ] }, { "cell_type": "code", "execution_count": null, "id": "4f4c4e03", "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": "5af13f65", "metadata": {}, "source": [ "Equivalent toml file looks like below " ] }, { "cell_type": "code", "execution_count": null, "id": "30ce526c", "metadata": {}, "outputs": [], "source": [ "toml_string = toml.dumps(cfg)\n", "print(toml_string)" ] }, { "cell_type": "markdown", "id": "69d55d14", "metadata": {}, "source": [ "## Apply config file" ] }, { "cell_type": "code", "execution_count": null, "id": "afe7bcf8", "metadata": {}, "outputs": [], "source": [ "edbapp.configuration.load(cfg_file_path, apply_file=True)" ] }, { "cell_type": "markdown", "id": "b4e2660d", "metadata": {}, "source": [ "Save and close Edb\n", "\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": "2d14b831", "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 }