{ "cells": [ { "cell_type": "markdown", "id": "3c58e430", "metadata": {}, "source": [ "# Convert encrypted 3D components\n", "\n", "The 2023R1 release of Ansys Electronics Desktop (AEDT) implemented a new [solid modeling kernel](https://en.wikipedia.org/wiki/Geometric_modeling_kernel).\n", "\n", "This example demonstrates how to easily migrate encrypted\n", "3D components from older versions of AEDT\n", "that relied on the ACIS modeling kernel, to the new\n", "versions of AEDT that employ\n", "the Parasolid kernel. Specifically, if your \n", "encrypted 3D\n", "components were created with version 22R2 or \n", "earlier, you'll need to convert them\n", "to a version ≥ 23R1 that supports the Parasolid modeler.\n", "\n", "Keywords: **HFSS**, **Encrypted**, **3D component**, **Modeler kernel**.\n", "\n", "" ] }, { "cell_type": "markdown", "id": "dbca2e70", "metadata": {}, "source": [ "## Prerequisites\n", "\n", "### Perform imports" ] }, { "cell_type": "code", "execution_count": null, "id": "599f8adc", "metadata": {}, "outputs": [], "source": [ "import os\n", "import tempfile\n", "import time\n", "\n", "from ansys.aedt.core import Desktop, Hfss, settings\n", "from ansys.aedt.core.examples.downloads import download_file" ] }, { "cell_type": "markdown", "id": "82b42395", "metadata": {}, "source": [ "### Define constants\n", "Constants help ensure consistency and avoid repetition throughout the example." ] }, { "cell_type": "code", "execution_count": null, "id": "7bc341f9", "metadata": {}, "outputs": [], "source": [ "AEDT_VERSION = \"2025.1\"\n", "OLD_AEDT_VERSION = \"2024.1\"\n", "NG_MODE = False # Open AEDT UI when AEDT is launched." ] }, { "cell_type": "markdown", "id": "07df6f26", "metadata": {}, "source": [ "### Create temporary directory\n", "\n", "Create a temporary working directory.\n", "The name of the working folder is stored in ``temp_folder.name``.\n", "\n", "> **Note:** The final cell in the notebook cleans up the temporary folder. If you want to\n", "> retrieve the AEDT project and data, do so before executing the final cell in the notebook." ] }, { "cell_type": "code", "execution_count": null, "id": "c4837632", "metadata": {}, "outputs": [], "source": [ "temp_folder = tempfile.TemporaryDirectory(suffix=\".ansys\")" ] }, { "cell_type": "markdown", "id": "21aa6162", "metadata": {}, "source": [ "## Covert the encrypted component\n", "\n", "### Retrieve the component that will be converted\n", "\n", "The ``download_file()`` method provides access to a library\n", "of examples and models from the Ansys GitHub organization: \n", "[example-data repository](https://github.com/ansys/example-data/tree/master/pyaedt). Download the \"old\"\n", "encrypted 3D component and define a name to use for the new, coverted component." ] }, { "cell_type": "code", "execution_count": null, "id": "67029309", "metadata": {}, "outputs": [], "source": [ "a3dcomp = download_file(\n", " source=\"component_3d\",\n", " name=\"SMA_Edge_Connector_23r2_encrypted_password_ansys.a3dcomp\",\n", " local_path=temp_folder.name,\n", ")\n", "\n", "# Name of the converted 3D component:\n", "new_component_filename = os.path.join(temp_folder.name, r\"SMA_Edge_Connector_encrypted.a3dcomp\")" ] }, { "cell_type": "markdown", "id": "30422da7", "metadata": {}, "source": [ "### Enable multiple desktop instances.\n", "\n", "This example runs two versions of AEDT simultaneously.\n", "\n", "> **Note:** Both the old and new versions of AEDT must be installed on the machine\n", "> where this example runs." ] }, { "cell_type": "code", "execution_count": null, "id": "9a0005c7", "metadata": {}, "outputs": [], "source": [ "settings.use_multi_desktop = True" ] }, { "cell_type": "markdown", "id": "82648641", "metadata": {}, "source": [ "### Load the encrypted 3D component.\n", "\n", "Launch the old version of AEDT and load the encrypted component.\n", "Pass the keyword argument ``aedt_process_id`` to ensure that the ``Hfss``\n", "instance connects to the correct running version of HFSS. The encryption\n", "password must be provided to enable conversion." ] }, { "cell_type": "code", "execution_count": null, "id": "da2c6e40", "metadata": {}, "outputs": [], "source": [ "aedt_old = Desktop(new_desktop=True, version=OLD_AEDT_VERSION)\n", "\n", "# Insert an empty HFSS design.\n", "hfss1 = Hfss(aedt_process_id=aedt_old.aedt_process_id, solution_type=\"Terminal\")\n", "\n", "# Insert the encrypted 3D component.\n", "cmp = hfss1.modeler.insert_3d_component(input_file=a3dcomp, password=\"ansys\")\n", "\n", "# Open the 3D component definition.\n", "app_comp = cmp.edit_definition(password=\"ansys\")" ] }, { "cell_type": "markdown", "id": "d5b7f8e8", "metadata": {}, "source": [ "### Convert the encrypted 3D component\n", "\n", "Launch another instance of AEDT to enable conversion of the\n", "3D component.\n", "\n", "After the new version of AEDT is started, the process ID \n", "is retrieved via the property ``aedt.aedt_process_id`` and is passed\n", "as an argument to `Hfss()`. This ensures that the newly created\n", "`hfss2` object\n", "is connected to the\n", "correct version and instance of AEDT." ] }, { "cell_type": "code", "execution_count": null, "id": "9b7b059f", "metadata": {}, "outputs": [], "source": [ "aedt = Desktop(new_desktop=True, version=AEDT_VERSION)\n", "\n", "# Insert an empty HFSS design.\n", "hfss2 = Hfss(aedt_process_id=aedt.aedt_process_id, solution_type=\"Terminal\")\n", "\n", "# Copy objects from the old design.\n", "hfss2.copy_solid_bodies_from(design=app_comp, no_vacuum=False, no_pec=False)\n", "\n", "# Create the new encrypted 3D component.\n", "hfss2.modeler.create_3dcomponent(\n", " input_file=new_component_filename,\n", " is_encrypted=True,\n", " edit_password=\"ansys\",\n", " hide_contents=False,\n", " allow_edit=True,\n", " password_type=\"InternalPassword\",\n", ")" ] }, { "cell_type": "markdown", "id": "81c84228", "metadata": {}, "source": [ "## Finish\n", "\n", "### Save the projects" ] }, { "cell_type": "code", "execution_count": null, "id": "5aa212a4", "metadata": {}, "outputs": [], "source": [ "aedt.save_project()\n", "aedt_old.save_project()\n", "aedt.release_desktop()\n", "aedt_old.release_desktop()\n", "print(f\"The new encrypted 3D component can be retrieved from: {new_component_filename}\")\n", "# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.\n", "time.sleep(3)" ] }, { "cell_type": "markdown", "id": "1801c298", "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": "cf6dc140", "metadata": {}, "outputs": [], "source": [ "temp_folder.cleanup()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 5 }