|
1 |
| -# # Encrypted 3D component conversion |
| 1 | +# # Convert encrypted 3D components |
2 | 2 | #
|
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. |
7 | 14 | #
|
8 | 15 | # Keywords: **HFSS**, **Encrypted**, **3D component**, **Modeler kernel**.
|
9 |
| - |
10 |
| -# <img src="_static/e3dcomp.png" width="500"> |
11 |
| - |
12 |
| -# ## Perform imports and define constants |
13 | 16 | #
|
14 |
| -# Import the required packages. |
| 17 | +# <img src="_static/e3dcomp.png" width="350"> |
| 18 | + |
| 19 | +# ## Prerequisites |
15 | 20 | #
|
| 21 | +# ### Perform imports |
16 | 22 |
|
| 23 | +# + |
17 | 24 | import os
|
18 | 25 | import tempfile
|
19 | 26 | import time
|
20 | 27 |
|
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 | +# - |
23 | 31 |
|
24 |
| -# Define constants. |
| 32 | +# ### Define constants |
| 33 | +# Constants help ensure consistency and avoid repetition throughout the example. |
25 | 34 |
|
26 | 35 | AEDT_VERSION = "2024.2"
|
27 | 36 | 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. |
30 | 38 |
|
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``. |
32 | 43 | #
|
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. |
37 | 46 |
|
38 | 47 | temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
|
39 | 48 |
|
40 |
| -# ## Download encrypted example |
| 49 | +# ## Covert the encrypted component |
41 | 50 | #
|
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. |
43 | 57 |
|
| 58 | +# + |
44 | 59 | 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", |
47 | 62 | destination=temp_folder.name,
|
48 | 63 | )
|
49 | 64 |
|
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. |
51 | 75 |
|
52 | 76 | settings.use_multi_desktop = True
|
53 | 77 |
|
54 |
| -# ## Prepare encrypted 3D component in ACIS |
| 78 | +# ### Load the encrypted 3D component. |
55 | 79 | #
|
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. |
57 | 84 |
|
| 85 | +# + |
58 | 86 | aedt_old = Desktop(new_desktop=True, version=OLD_AEDT_VERSION)
|
59 | 87 |
|
60 | 88 | # Insert an empty HFSS design.
|
61 |
| - |
62 | 89 | hfss1 = Hfss(aedt_process_id=aedt_old.aedt_process_id, solution_type="Terminal")
|
63 | 90 |
|
64 | 91 | # Insert the encrypted 3D component.
|
| 92 | +cmp = hfss1.modeler.insert_3d_component(input_file=a3dcomp, password="ansys") |
65 | 93 |
|
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. |
70 | 95 | app_comp = cmp.edit_definition(password="ansys")
|
| 96 | +# - |
71 | 97 |
|
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. |
73 | 102 | #
|
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. |
75 | 109 |
|
76 |
| -aedt = Desktop(new_desktop_session=True, specified_version=AEDT_VERSION) |
| 110 | +# + |
| 111 | +aedt = Desktop(new_desktop=True, version=AEDT_VERSION) |
77 | 112 |
|
78 | 113 | # Insert an empty HFSS design.
|
79 |
| - |
80 | 114 | hfss2 = Hfss(aedt_process_id=aedt.aedt_process_id, solution_type="Terminal")
|
81 | 115 |
|
82 | 116 | # Copy objects from the old design.
|
83 |
| - |
84 | 117 | hfss2.copy_solid_bodies_from(design=app_comp, no_vacuum=False, no_pec=False)
|
85 | 118 |
|
86 | 119 | # Create the new encrypted 3D component.
|
87 |
| - |
88 | 120 | 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, |
90 | 122 | is_encrypted=True,
|
91 | 123 | edit_password="ansys",
|
92 | 124 | hide_contents=False,
|
93 | 125 | allow_edit=True,
|
94 | 126 | password_type="InternalPassword",
|
95 | 127 | )
|
| 128 | +# - |
96 | 129 |
|
97 |
| -# ## Release AEDT |
| 130 | +# ## Finish |
| 131 | +# |
| 132 | +# ### Save the projects |
98 | 133 |
|
99 | 134 | aedt.save_project()
|
100 | 135 | aedt_old.save_project()
|
101 | 136 | aedt.release_desktop()
|
102 | 137 | aedt_old.release_desktop()
|
| 138 | +print(f"The new encrypted 3D component can be retrieved from: {new_component_filename}") |
103 | 139 | # Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
|
104 | 140 | time.sleep(3)
|
105 | 141 |
|
106 |
| -# ## Clean up |
| 142 | +# ### Clean up |
107 | 143 | #
|
108 | 144 | # All project files are saved in the folder ``temp_folder.name``.
|
109 | 145 | # If you've run this example as a Jupyter notebook, you
|
|
0 commit comments