Skip to content

Commit a10609d

Browse files
DOCS: Update component_conversion.py (#294)
1 parent 13bfeb1 commit a10609d

File tree

2 files changed

+258
-148
lines changed

2 files changed

+258
-148
lines changed

examples/aedt_general/components/component_conversion.py

+77-41
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,145 @@
1-
# # Encrypted 3D component conversion
1+
# # Convert encrypted 3D components
22
#
3-
# This example shows how to convert an encrypted
4-
# 3D component from ACIS to Parasolid in different AEDT releases.
5-
# If you have models previous to Ansys AEDT 2023 R1 with an ACIS kernel,
6-
# you can convert it to Parasolid.
3+
# The 2023R1 release of Ansys Electronics Desktop (AEDT) implemented a new [solid modeling kernel](https://en.wikipedia.org/wiki/Geometric_modeling_kernel).
4+
#
5+
# This example demonstrates how to easily migrate encrypted
6+
# 3D components from older versions of AEDT
7+
# that relied on the ACIS modeling kernel, to the new
8+
# versions of AEDT that employ
9+
# the Parasolid kernel. Specifically, if your
10+
# encrypted 3D
11+
# components were created with version 22R2 or
12+
# earlier, you'll need to convert them
13+
# to a version ≥ 23R1 that supports the Parasolid modeler.
714
#
815
# Keywords: **HFSS**, **Encrypted**, **3D component**, **Modeler kernel**.
9-
10-
# <img src="_static/e3dcomp.png" width="500">
11-
12-
# ## Perform imports and define constants
1316
#
14-
# Import the required packages.
17+
# <img src="_static/e3dcomp.png" width="350">
18+
19+
# ## Prerequisites
1520
#
21+
# ### Perform imports
1622

23+
# +
1724
import os
1825
import tempfile
1926
import time
2027

21-
from pyaedt import Desktop, Hfss, settings
22-
from pyedb.misc.downloads import download_file
28+
from ansys.aedt.core import Desktop, Hfss, settings
29+
from ansys.aedt.core.downloads import download_file
30+
# -
2331

24-
# Define constants.
32+
# ### Define constants
33+
# Constants help ensure consistency and avoid repetition throughout the example.
2534

2635
AEDT_VERSION = "2024.2"
2736
OLD_AEDT_VERSION = "2024.1"
28-
NUM_CORES = 4
29-
NG_MODE = False # Open AEDT UI when it is launched.
37+
NG_MODE = False # Open AEDT UI when AEDT is launched.
3038

31-
# ## Create temporary directory
39+
# ### Create temporary directory
40+
#
41+
# Create a temporary working directory.
42+
# The name of the working folder is stored in ``temp_folder.name``.
3243
#
33-
# Create a temporary directory where downloaded data or
34-
# dumped data can be stored.
35-
# If you'd like to retrieve the project data for subsequent use,
36-
# the temporary folder name is given by ``temp_folder.name``.
44+
# > **Note:** The final cell in the notebook cleans up the temporary folder. If you want to
45+
# > retrieve the AEDT project and data, do so before executing the final cell in the notebook.
3746

3847
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
3948

40-
# ## Download encrypted example
49+
# ## Covert the encrypted component
4150
#
42-
# Download the encrypted 3D component example.
51+
# ### Retrieve the component that will be converted
52+
#
53+
# The ``download_file()`` method provides access to a library
54+
# of examples and models from the Ansys GitHub organization:
55+
# [example-data repository](https://github.com/ansys/example-data/tree/master/pyaedt). Download the "old"
56+
# encrypted 3D component and define a name to use for the new, coverted component.
4357

58+
# +
4459
a3dcomp = download_file(
45-
directory="component_3d",
46-
filename="SMA_Edge_Connector_23r2_encrypted_password_ansys.a3dcomp",
60+
source="component_3d",
61+
name="SMA_Edge_Connector_23r2_encrypted_password_ansys.a3dcomp",
4762
destination=temp_folder.name,
4863
)
4964

50-
# ## Enable multiple desktop support
65+
# Name of the converted 3D component:
66+
new_component_filename = os.path.join(temp_folder.name, r"SMA_Edge_Connector_encrypted.a3dcomp")
67+
# -
68+
69+
# ### Enable multiple desktop instances.
70+
#
71+
# This example runs two versions of AEDT simultaneously.
72+
#
73+
# > **Note:** Both the old and new versions of AEDT must be installed on the machine
74+
# > where this example runs.
5175

5276
settings.use_multi_desktop = True
5377

54-
# ## Prepare encrypted 3D component in ACIS
78+
# ### Load the encrypted 3D component.
5579
#
56-
# Launch the old AEDT release.
80+
# Launch the old version of AEDT and load the encrypted component.
81+
# Pass the keyword argument ``aedt_process_id`` to ensure that the ``Hfss``
82+
# instance connects to the correct running version of HFSS. The encryption
83+
# password must be provided to enable conversion.
5784

85+
# +
5886
aedt_old = Desktop(new_desktop=True, version=OLD_AEDT_VERSION)
5987

6088
# Insert an empty HFSS design.
61-
6289
hfss1 = Hfss(aedt_process_id=aedt_old.aedt_process_id, solution_type="Terminal")
6390

6491
# Insert the encrypted 3D component.
92+
cmp = hfss1.modeler.insert_3d_component(input_file=a3dcomp, password="ansys")
6593

66-
cmp = hfss1.modeler.insert_3d_component(comp_file=a3dcomp, password="ansys")
67-
68-
# Open the 3D component in an HFSS design.
69-
94+
# Open the 3D component definition.
7095
app_comp = cmp.edit_definition(password="ansys")
96+
# -
7197

72-
# ## Create an encrypted 3D component in Parasolid
98+
# ### Convert the encrypted 3D component
99+
#
100+
# Launch another instance of AEDT to enable conversion of the
101+
# 3D component.
73102
#
74-
# Launch the new AEDT release
103+
# After the new version of AEDT is started, the process ID
104+
# is retrieved via the property ``aedt.aedt_process_id`` and is passed
105+
# as an argument to `Hfss()`. This ensures that the newly created
106+
# `hfss2` object
107+
# is connected to the
108+
# correct version and instance of AEDT.
75109

76-
aedt = Desktop(new_desktop_session=True, specified_version=AEDT_VERSION)
110+
# +
111+
aedt = Desktop(new_desktop=True, version=AEDT_VERSION)
77112

78113
# Insert an empty HFSS design.
79-
80114
hfss2 = Hfss(aedt_process_id=aedt.aedt_process_id, solution_type="Terminal")
81115

82116
# Copy objects from the old design.
83-
84117
hfss2.copy_solid_bodies_from(design=app_comp, no_vacuum=False, no_pec=False)
85118

86119
# Create the new encrypted 3D component.
87-
88120
hfss2.modeler.create_3dcomponent(
89-
input_file=os.path.join(temp_folder.name, r"SMA_Edge_Connector_encrypted.a3dcomp"),
121+
input_file=new_component_filename,
90122
is_encrypted=True,
91123
edit_password="ansys",
92124
hide_contents=False,
93125
allow_edit=True,
94126
password_type="InternalPassword",
95127
)
128+
# -
96129

97-
# ## Release AEDT
130+
# ## Finish
131+
#
132+
# ### Save the projects
98133

99134
aedt.save_project()
100135
aedt_old.save_project()
101136
aedt.release_desktop()
102137
aedt_old.release_desktop()
138+
print(f"The new encrypted 3D component can be retrieved from: {new_component_filename}")
103139
# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
104140
time.sleep(3)
105141

106-
# ## Clean up
142+
# ### Clean up
107143
#
108144
# All project files are saved in the folder ``temp_folder.name``.
109145
# If you've run this example as a Jupyter notebook, you

0 commit comments

Comments
 (0)