{ "cells": [ { "cell_type": "markdown", "id": "eb89efdc", "metadata": {}, "source": [ "# Import of a PCB and its components via IDF and EDB" ] }, { "cell_type": "markdown", "id": "3077582c", "metadata": {}, "source": [ "This example shows how to import a PCB and its components using IDF files (LDB and BDF).\n", "You can also use a combination of EMN and EMP files in a similar way.\n", "\n", "Keywords: **Icepak**, **PCB**, **IDF**." ] }, { "cell_type": "markdown", "id": "bee21b86", "metadata": {}, "source": [ "## Perform imports and define constants\n", "\n", "Perform required imports." ] }, { "cell_type": "code", "execution_count": null, "id": "5e86c65c", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time" ] }, { "cell_type": "code", "execution_count": null, "id": "37e227ab", "metadata": {}, "outputs": [], "source": [ "import ansys.aedt.core\n", "from ansys.aedt.core import Hfss3dLayout, Icepak" ] }, { "cell_type": "markdown", "id": "203cd113", "metadata": {}, "source": [ "Define constants." ] }, { "cell_type": "code", "execution_count": null, "id": "56a5ce4b", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2024.2\"\n", "NG_MODE = False # Open AEDT UI when it is launched." ] }, { "cell_type": "markdown", "id": "d27aad64", "metadata": {}, "source": [ "## Open project\n", "\n", "Open an empty project in non-graphical mode, using a temporary folder." ] }, { "cell_type": "code", "execution_count": null, "id": "26b6bd1e", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")\n", "\n", "ipk = Icepak(\n", " project=os.path.join(temp_folder.name, \"Icepak_ECAD_Import.aedt\"),\n", " version=AEDT_VERSION,\n", " new_desktop=True,\n", " non_graphical=NG_MODE,\n", ")" ] }, { "cell_type": "markdown", "id": "4e221b67", "metadata": {}, "source": [ "## Import the IDF files\n", "\n", "Import the BDF and LDF files. Sample files are shown here.\n", "\n", "\n", "\n", "\n", "\n", "You can import the IDF files with several filtering options, including caps, resistors,\n", "inductors, power, specific power, and size.\n", "There are also options for PCB creation, including number of layers, copper percentages, and layer sizes.\n", "\n", "This example uses the default values for the PCB.\n", "The imported PCB (from the IDF files) are deleted later and replaced by a PCB that has the trace\n", "information (from ECAD) for higher accuracy." ] }, { "cell_type": "markdown", "id": "5ffcc665", "metadata": {}, "source": [ "Download ECAD and IDF files." ] }, { "cell_type": "code", "execution_count": null, "id": "b73be4ce", "metadata": {}, "outputs": [], "source": [ "def_path = ansys.aedt.core.downloads.download_file(\n", " source=\"icepak/Icepak_ECAD_Import/A1_uprev.aedb\",\n", " name=\"edb.def\",\n", " destination=temp_folder.name,\n", ")\n", "board_path = ansys.aedt.core.downloads.download_file(\n", " source=\"icepak/Icepak_ECAD_Import/\", name=\"A1.bdf\", destination=temp_folder.name\n", ")\n", "library_path = ansys.aedt.core.downloads.download_file(\n", " source=\"icepak/Icepak_ECAD_Import/\", name=\"A1.ldf\", destination=temp_folder.name\n", ")" ] }, { "cell_type": "markdown", "id": "7e21085e", "metadata": {}, "source": [ "Import IDF file." ] }, { "cell_type": "code", "execution_count": null, "id": "f66a7743", "metadata": {}, "outputs": [], "source": [ "ipk.import_idf(board_path=board_path)" ] }, { "cell_type": "markdown", "id": "6366eb3a", "metadata": {}, "source": [ "Save the project" ] }, { "cell_type": "code", "execution_count": null, "id": "89d522c3", "metadata": {}, "outputs": [], "source": [ "ipk.save_project()" ] }, { "cell_type": "markdown", "id": "ceff3336", "metadata": {}, "source": [ "## Import ECAD\n", "Add an HFSS 3D Layout design with the layout information of the PCB." ] }, { "cell_type": "code", "execution_count": null, "id": "af3894d1", "metadata": {}, "outputs": [], "source": [ "hfss3d_lo = Hfss3dLayout(project=def_path, version=AEDT_VERSION)\n", "hfss3d_lo.save_project()" ] }, { "cell_type": "markdown", "id": "da18a073", "metadata": {}, "source": [ "Create a PCB component in Icepak linked to the HFSS 3D Layout project. The polygon ``\"poly_0\"``\n", "is used as the outline of the PCB, and a dissipation of ``\"1W\"`` is applied to the PCB." ] }, { "cell_type": "code", "execution_count": null, "id": "d30d9e91", "metadata": {}, "outputs": [], "source": [ "project_file = hfss3d_lo.project_file\n", "design_name = hfss3d_lo.design_name" ] }, { "cell_type": "code", "execution_count": null, "id": "2de51e90", "metadata": {}, "outputs": [], "source": [ "ipk.create_pcb_from_3dlayout(\n", " component_name=\"PCB_pyAEDT\",\n", " project_name=project_file,\n", " design_name=design_name,\n", " extent_type=\"Polygon\",\n", " outline_polygon=\"poly_0\",\n", " power_in=1,\n", " close_linked_project_after_import=False,\n", ")" ] }, { "cell_type": "markdown", "id": "db47db44", "metadata": {}, "source": [ "Delete the simplified PCB object coming from the IDF import." ] }, { "cell_type": "code", "execution_count": null, "id": "49df7fda", "metadata": {}, "outputs": [], "source": [ "ipk.modeler.delete_objects_containing(\"IDF_BoardOutline\", False)" ] }, { "cell_type": "markdown", "id": "328676f3", "metadata": {}, "source": [ "## Release AEDT" ] }, { "cell_type": "code", "execution_count": null, "id": "87a9b93f", "metadata": {}, "outputs": [], "source": [ "ipk.save_project()\n", "ipk.release_desktop()\n", "# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "61590f47", "metadata": {}, "source": [ "## Clean up\n", "\n", "All project files are saved in the folder ``temp_folder.name``.\n", "If you've run this example as a Jupyter notebook, you\n", "can retrieve those project files. The following cell\n", "removes all temporary files, including the project folder." ] }, { "cell_type": "code", "execution_count": null, "id": "5492ee2d", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }