Hello Mike, Hello mjmiddle,
So there has been some progress. I did minor changes through which my script is now generating a CSV file for every Design Point I am updating through the Parameter Set. But the results are not getting stored in those files. When I manually run the script in Mechanical, only then are the results getting saved in the generated CSV files.
For your reference, here is the actual code that I am using:
def after_post(this, solution):# Do not edit this line
"""
Called after post processing.
Keyword Arguments :
this -- the datamodel object instance of the python code object you are currently editing in the tree
solution -- Solution
"""
# User Dir
import os
import csv
import wbjn
userfilesdir = wbjn.ExecuteCommand(ExtAPI,"""returnValue(GetUserFilesDirectory())""")
#DPValue as parameter
DPValue = this.GetCustomPropertyByPath("Parameter/DPValue").Value
dpn = "DP_"+str(int(DPValue))
file_name = os.path.join(userfilesdir, dpn+"data.csv")
file_handle = open(file_name, "wb")
ResultsOfInterest = []
for i in range(1,5):
ResultsOfInterest.append(ExtAPI.DataModel.AnalysisList[0].Solution.Children[i].Name)
solution=ExtAPI.DataModel.AnalysisList[0].Solution
for j, item in enumerate(solution.Children):
if item.GetType() == Ansys.ACT.Automation.Mechanical.Results.ThermalResults.TemperatureResult:
if item.Name in ResultsOfInterest:
item.Activate()
Pane=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData)
Con = Pane.ControlUnknown
for R in range(1,Con.RowsCount+1):
for C in range(2,Con.ColumnsCount+1):
cellText = Con.cell(R, C).Text
file_handle.write("%s;" % cellText)
file_handle.write("\n")
file_handle.close()
pass
Do you have any suggesstions?
Regards,
Akshay