Download this example

Download this example as a Jupyter Notebook or as a Python script.


Encrypted 3D component conversion#

This example shows how to convert an encrypted 3D component from ACIS to Parasolid in different AEDT releases. If you have models previous to Ansys AEDT 2023 R1 with an ACIS kernel, you can convert it to Parasolid.

Keywords: HFSS, Encrypted, 3D component, Modeler kernel.

b2c9c9f36a4f4a1a8c2d35320daa5f11

Perform imports and define constants#

Import the required packages.

[1]:
import os
import tempfile
import time
[2]:
from pyaedt import Desktop, Hfss, settings
from pyedb.misc.downloads import download_file
FutureWarning: Module 'pyaedt' has become an alias to the new package structure. Please update you imports to use the new architecture based on 'ansys.aedt.core'. In addition, some files have been renamed to follow the PEP 8 naming convention. The old structure and file names will be deprecated in future versions, see https://aedt.docs.pyansys.com/version/stable/release_1_0.html

Define constants.

[3]:
AEDT_VERSION = "2024.2"
OLD_AEDT_VERSION = "2024.1"
NUM_CORES = 4
NG_MODE = False  # Open AEDT UI when it is launched.

Create temporary directory#

Create a temporary directory where downloaded data or dumped data can be stored. If you’d like to retrieve the project data for subsequent use, the temporary folder name is given by temp_folder.name.

[4]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")

Download encrypted example#

Download the encrypted 3D component example.

[5]:
a3dcomp = download_file(
    directory="component_3d",
    filename="SMA_Edge_Connector_23r2_encrypted_password_ansys.a3dcomp",
    destination=temp_folder.name,
)

Enable multiple desktop support#

[6]:
settings.use_multi_desktop = True

Prepare encrypted 3D component in ACIS#

Launch the old AEDT release.

[7]:
aedt_old = Desktop(new_desktop=True, version=OLD_AEDT_VERSION)
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT INFO: Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_49cd9cbb-e671-4fc6-99d3-a8e9c87e03eb.log is enabled.
PyAEDT INFO: Log on AEDT is enabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 53233
PyAEDT INFO: AEDT installation Path C:\Program Files\AnsysEM\v241\Win64
PyAEDT INFO: Ansoft.ElectronicsDesktop.2024.1 version started with process ID 2180.

Insert an empty HFSS design.

[8]:
hfss1 = Hfss(aedt_process_id=aedt_old.aedt_process_id, solution_type="Terminal")
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Project Project1 has been created.
PyAEDT INFO: No design is present. Inserting a new design.
PyAEDT INFO: Added design 'HFSS_F4I' of type HFSS.
PyAEDT INFO: Aedt Objects correctly read

Insert the encrypted 3D component.

[9]:
cmp = hfss1.modeler.insert_3d_component(comp_file=a3dcomp, password="ansys")
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 1sec
PyAEDT WARNING: Argument `comp_file` is deprecated for method `insert_3d_component`; use `input_file` instead.

Open the 3D component in an HFSS design.

[10]:
app_comp = cmp.edit_definition(password="ansys")
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Project HFSSDesign1 set to active.
PyAEDT INFO: Aedt Objects correctly read

Create an encrypted 3D component in Parasolid#

Launch the new AEDT release

[11]:
aedt = Desktop(new_desktop_session=True, specified_version=AEDT_VERSION)
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Initializing new Desktop session.
PyAEDT WARNING: Argument `specified_version` is deprecated for method `__init__`; use `version` instead.
PyAEDT WARNING: Argument `new_desktop_session` is deprecated for method `__init__`; use `new_desktop` instead.
PyAEDT INFO: Log on console is enabled.
PyAEDT INFO: Log on file C:\Users\ansys\AppData\Local\Temp\pyaedt_ansys_49cd9cbb-e671-4fc6-99d3-a8e9c87e03eb.log is enabled.
PyAEDT INFO: Log on AEDT is disabled.
PyAEDT INFO: Debug logger is disabled. PyAEDT methods will not be logged.
PyAEDT INFO: Launching PyAEDT with gRPC plugin.
PyAEDT INFO: New AEDT session is starting on gRPC port 53411
PyAEDT INFO: AEDT installation Path C:\Program Files\AnsysEM\v242\Win64
PyAEDT INFO: Ansoft.ElectronicsDesktop.2024.2 version started with process ID 256.

Insert an empty HFSS design.

[12]:
hfss2 = Hfss(aedt_process_id=aedt.aedt_process_id, solution_type="Terminal")
PyAEDT INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyAEDT INFO: PyAEDT version 0.12.dev0.
PyAEDT INFO: Project Project97 has been created.
PyAEDT INFO: No design is present. Inserting a new design.
PyAEDT INFO: Added design 'HFSS_YLN' of type HFSS.
PyAEDT INFO: Aedt Objects correctly read

Copy objects from the old design.

[13]:
hfss2.copy_solid_bodies_from(design=app_comp, no_vacuum=False, no_pec=False)
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Modeler class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Parsing design objects. This operation can take time
PyAEDT INFO: Parsing C:/Users/ansys/Documents/Ansoft/HFSSDesign1.aedt.
PyAEDT INFO: File C:/Users/ansys/Documents/Ansoft/HFSSDesign1.aedt correctly loaded. Elapsed time: 0m 0sec
PyAEDT INFO: aedt file load time 0.20559453964233398
PyAEDT INFO: 3D Modeler objects parsed. Elapsed time: 0m 1sec
[13]:
True

Create the new encrypted 3D component.

[14]:
hfss2.modeler.create_3dcomponent(
    input_file=os.path.join(temp_folder.name, r"SMA_Edge_Connector_encrypted.a3dcomp"),
    is_encrypted=True,
    edit_password="ansys",
    hide_contents=False,
    allow_edit=True,
    password_type="InternalPassword",
)
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
PyAEDT INFO: Mesh class has been initialized! Elapsed time: 0m 0sec
[14]:
True

Release AEDT#

[15]:
aedt.save_project()
aedt_old.save_project()
aedt.release_desktop()
aedt_old.release_desktop()
# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
time.sleep(3)
PyAEDT INFO: Desktop has been released and closed.
PyAEDT INFO: Desktop has been released and closed.

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.

[16]:
temp_folder.cleanup()

Download this example

Download this example as a Jupyter Notebook or as a Python script.