How can I export temperature result data in Mechanical to a csv file using a Python code object?

Options
arranosr71
arranosr71 Member Posts: 1

Hello everyone, it is my first post in this forum.

I have a thermal model in ANSYS Mechanical with a couple of interesting temperature result objects on it. The thing is I'd like to create a Python code object that automatically exports these results every time the simulation is completed (the same way as doing a right-clik ->Export Text File on the interface).

Is there any way of doing that?

Thank you all for your attention

Answers

  • Abel Ramos
    Abel Ramos Member, Employee Posts: 30
    5 Likes First Answer First Comment First Anniversary
    Options

    Hello, you could investigate using something in this direction:

    import os
    
    analysis=ExtAPI.DataModel.Project.Model.Analyses[0]
    lotationToExport = analysis.WorkingDir
    fileName = "exported.txt"
    fileToExport = os.path.join(lotationToExport,fileName)
    
    #Use your results name here
    resultsName = "myResultName"
    r1=ExtAPI.DataModel.GetObjectsByName(resultsName)[0]
    r1.ExportToTextFile(fileToExport)