I finally found a solution which is working according to my, or our liking. I am able to export the results in Tablular Data for all the selected Solution Objects while the Design Points update through Workbench. I used a different script which does not need to access the User Interface Pane command to read the results. From what I understood, the UserInterface.GetPane command needs the Mechanical GUI to be open in order to work. So I found a workaround after interacting with ANSYS employees regarding this problem. You also don't need to make any changes in the Property Provider in order to get the active Design Point number. Initially while executing this script, Workbench used to crash. So I updated it from 2022 R2 to 2023 R2. And now it works perfectly.
I am posting the script here. Let me know if it works for you. I will suggest to use the latest version of Workbench for this script to work. Otherwise it will crash.
Also, the main parts of the code which I thought were necessary for successful execution of the script have been highlighted in bold. Rest of the parts you can edit according to your needs.
####Things to note:
###Create a Python Code Object in Solution
###Set the Target Callback under Definition of the Python Code Object to 'After Post'
###Paste the below written code into the Python Code Object
###Connect the Python Code Object
#If you want this code to run for multiple design points in a Parameter Set, ensure that the Python Code Object stays connected every time Mechanical is opened. This can be ensured in Workbench as follows:
#Workbench -> Tools -> Options -> Mechanical -> Check the box "Connect/Run Python Code Objects When Mechanical is launched"
#This command returns the user files directory where the CSV files will get stored. It can be changed to any other target folder of choice.
userfilesdir = wbjn.ExecuteCommand(ExtAPI,"""returnValue(GetUserFilesDirectory())""")
#This command returns the active design point from the Parameter Set
file_name = os.path.join(userfilesdir, dpn+"data.csv")
file_handle = open(file_name, "w")
#Returns units of the desired quantities which you want to be written in the CSV file. Write the desired quantity name in string format.
time_unit = ExtAPI.DataModel.CurrentUnitFromQuantityName("Time")
temp_unit = ExtAPI.DataModel.CurrentUnitFromQuantityName("Temperature")
#Create an empty list here where target result quantities will be stored.
#Append the names of the target result quantities in string format.
ResultsOfInterest = 
#Accesses the solution of the project through ACT API
#Accesses the counts of time steps through result object
### VERY IMPORTANT: THE DEFINITION OF THE DESIRED SOLUTION OBJECT MUST BE SET TO "RESULT SET". THIS CAN BE DONE AS FOLLOWS ###
### SOLUTION -> DESIRED SOLUTION OBJECT(S) -> DEFINITION -> BY -> RESULT SET ###
### IF THIS IS NOT DONE; THE CODE WON'T WORK ###
reader = Model.Analyses.GetResultsData()
rsets = reader.ResultSetCount
#This loop here loops through the Solution Objects one by one. It verifies if the name of the solution object is
#present in the list created before. If yes, it activates that solution object. After that, the code reads
#all the result values for all the time steps in the particular solution object(s) and saves these results into the CSV file
#which was defined previously
for sol_obj in solution.Children:
if sol_obj.GetType() == Ansys.ACT.Automation.Mechanical.Results.ThermalResults.TemperatureResult:
if sol_obj.Name in ResultsOfInterest:
#n += 1
sol_obj.By = Ansys.Mechanical.DataModel.Enums.SetDriverStyle.ResultSet
for rset in range(1,rsets+1):
sol_obj.SetNumber = rset
result_avg = sol_obj.Average
result_max = sol_obj.Maximum
result_min = sol_obj.Minimum
result_tstep = rset
file_handle.write("%s;" % result_tstep)
file_handle.write("%s;" % result_min)
file_handle.write("%s;" % result_max)
file_handle.write("%s;" % result_avg)
Let me know if you are able to run it. The only drawback is that the results get stored in string format along with their units in the CSV file. But that is something that can be dealt with later using Python, or any other programming tool. As I said, let me know how it works.