Accessing Mesh and Result Data Directly Using PyAEDT #5091
-
Hi, I'm currently working on a project where I need to access the mesh data and result data of my model using PyAEDT. However, I haven't been able to find a direct method within PyAEDT to retrieve this information. To achieve this, I've been using a workaround by exporting the mesh data and result data into .case files, which I then process separately. Below is a sample of the code I use for exporting this data: import pyaedt
file_path = r"path\to\aedt\file"
exports_folder_path = r"path\to\exports\folder"
desktop = pyaedt.Desktop()
prj= desktop.load_project(file_path)
model = prj.modeler
model.object_names
post = prj.post # post_processor
#Exporting Mesh
mesh_plot = post.create_fieldplot_volume(["coil1"],quantityName="Mesh",plot_name="Mesh_plot")
post.export_field_plot(plotname = "Mesh_plot",
filepath = exports_folder_path,
filename = "Mesh_data",
file_format = 'case'
)
mesh_plot.delete()
#Exporting Result
h_field_plot = post.create_fieldplot_volume(["coil1"],quantityName="H_Vector",plot_name="H_vector_plot")
post.export_field_plot(plotname = "H_vector_plot",
filepath = exports_folder_path,
filename = "h_vector",
file_format = 'case'
)
h_field_plot.delete()
desktop.close_desktop() Download the sample aedt file from this link. I'm specifically interested in accessing:
Is there a built-in functionality in PyAEDT that allows for direct access to this data without the need for exporting to external files? Any guidance on this would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @chamanth-vct , You need to export the data, but once you have it you can use PyVista to get this data. PyAEDT already has a method which is doing all the job for you: mesh_data = post.plot_field(quantity="Mesh", assignment=["coil1"], show=False) Then if you access the object you can get all the data: mesh_data.fields This object is a PyAEDT object called "ModelPlotter", you can build it with the .case file, but you will need more steps: |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. I see that the method you suggested still involves exporting the data, with the added benefit of automatically loading it into PyVista for plotting. While this is great for visualization, my focus isn't on plotting. What I’m specifically looking for is a way to directly access the mesh and result data through the PyAEDT API without the need to export to external files. Is there any functionality within PyAEDT that allows for this direct access? Any additional insights or guidance would be highly appreciated. Thank you |
Beta Was this translation helpful? Give feedback.
-
I wanted to kindly follow up on my previous inquiry regarding the possibility of directly accessing the mesh and result data through the PyAEDT, without the need to export to external files. The reason I am particularly interested in this is that I’ve encountered several issues when exporting field results, which I've detailed in issue #5182 . If there is a method to bypass the export process, it would significantly streamline our workflow and enable us to automate various operations within Ansys Electronics Desktop using PyAEDT. Any guidance or suggestions you can provide would be greatly appreciated. Thank you for your time and support. |
Beta Was this translation helpful? Give feedback.
Hi @chamanth-vct ,
You need to export the data, but once you have it you can use PyVista to get this data.
PyAEDT already has a method which is doing all the job for you:
mesh_data = post.plot_field(quantity="Mesh", assignment=["coil1"], show=False)
Then if you access the object you can get all the data: mesh_data.fields
This object is a PyAEDT object called "ModelPlotter", you can build it with the .case file, but you will need more steps:
https://aedt.docs.pyansys.com/version/stable/API/_autosummary/ansys.aedt.core.generic.plot.ModelPlotter.html#ansys.aedt.core.generic.plot.ModelPlotter