Akshay Panchwagh

Hello mjmiddle,

I tried to use a modified version of this script to save the tabular results in a CSV file for a Parameter Set I am evaluating. However, when I try to update the Design Points through Workbench, the script does not work at all. Only when I manually run the simulations through Mechanical does the script store results in a CSV file. I have written the script in a Python Code Object. Can you please let me know what might be going worng? I have been stuck on this issue for many days now. I need to extract these results since I need the temperature values for all the time steps (I am performing transient thermal simuations). 


For your reference, I am sharing the script that I am using for my use-case. The Property Provider has been modified to include the Design Point number as a Parameter.



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
    UserDir = os.path.dirname(ExtAPI.DataModel.AnalysisList[0].WorkingDir) + "\..\..\..\user_files\\"

    # DPValue as parameter

    DPValue = this.GetCustomPropertyByPath("Parameter/DPValue").Value
    dpn = "DP_"+str(int(DPValue))
    def writeCSV(filename, data):

    #Function to write python list to a csv file
        with open(filename, 'wb') as csvfile:

            spamwriter = csv.writer(csvfile, delimiter=';', quotechar='|', quoting=csv.QUOTE_MINIMAL)

            for row in data:

    ResultsOfInterest = []

    cmd = 'returnValue(GetUserFilesDirectory())'
    user_dir = wbjn.ExecuteCommand(ExtAPI, cmd)

    for j, item in enumerate(solution.Children):

        if item.GetType() == Ansys.ACT.Automation.Mechanical.Results.ThermalResults.TemperatureResult:
            if item.Name in ResultsOfInterest:


                del data[:]


                Con = Pane.ControlUnknown

                for R in range(1,Con.RowsCount+1):


                    for C in range(2,Con.ColumnsCount+1):

                    writeCSV(user_dir + "/" + Model.Analyses[0].Name + " - " + item.Name +dpn+ ".csv", data)



This script was originally written by one Pat Tessaro of Ozen Engineering Inc. I have modified the script which I found on their blogpost.