Issue Generating Field Plots Using PyAEDT

Hi Everyone,

I am encountering issues while generating and exporting field plots using PyAEDT. The process fails with the following error messages displayed in the AEDT Message Manager as shown in the screenshot:

"Script macro error: Plot H_vector_plot is not valid. Make sure this plot is updated before export"

image

However, when I perform the same steps manually through the AEDT GUI, the process completes successfully without any errors (as demonstrated in the attached GIF).

Steps To Reproduce:

Use the provided Python code snippet (below) to reproduce the issue. Download and use the sample aedt file from this link.

import ansys.aedt.core 
from pathlib import Path
import pyvista as pv

folder_path = Path(r"C:/Users/ch/aedt_sample_file")
file_path =  folder_path.joinpath("Project3.aedt")

desktop = ansys.aedt.core.Desktop() 
prj= desktop.load_project(file_path.__str__())
prj.set_auto_open(enable=False)
model = prj.modeler
part_names = model.object_names
post = prj.post  # post_processor

part_list = ['Ground'] 

for name in part_list:
    obj =  model.get_object_from_name(name)
    if obj.solve_inside:
        h_field_plot = post.create_fieldplot_volume([name],quantity="Vector_H",
                                                    plot_name="H_vector_plot")
    else:
        h_field_plot = post.create_fieldplot_surface(obj.faces,quantity="Vector_H",
                                                    plot_name="H_vector_plot",
                                                    intrinsics=prj.setups[0].default_intrinsics)

    export_status = post.export_field_plot(plot_name = "H_vector_plot",
                            output_dir = "C:/Users/ch/aedt_sample_file",
                            file_name = "h_vector",
                            file_format = 'case')
    h_field_plot.delete()

prj.close_project()
desktop.close_desktop()

The Python code generates the H Vector field plot for the Ground object and attempts to export it into .case format.

Question:

How can I resolve this issue when using PyAEDT? Any insights or suggestions would be greatly appreciated.

Thanks

Regards