How to export Mode number vs Frequency table from Modal Analysis?

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 174
100 Comments Photogenic Ansys Employee 5 Likes
✭✭✭✭

How to export the below table?

Comments

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 174
    100 Comments Photogenic Ansys Employee 5 Likes
    ✭✭✭✭
    edited August 7

    One can use the below script to export this table from the First analysis in the Tree from a Result Object with name "Total Deformation".

    import os
    import wbjn
    
    currAnalysis = DataModel.AnalysisList[0]
    UserFilesDir = wbjn.ExecuteCommand(ExtAPI,"returnValue(GetUserFilesDirectory())")
    
    def writeCSV(t1,fileName):
        ExtAPI.Log.WriteMessage('my File name ' + fileName)
        with open(fileName , 'w') as f:
            for line in t1:
                for col in line:
                    #For Non-German
                    #f.write(str(col) + ', ')
                    #For German OS - Delimiter 
                    f.write(str(col).replace(".",",") + '; ')
                f.write('\n')
    
    ResultName = "Total Deformation"
    
    ResultObj = [child for child in currAnalysis.Solution.Children if child.Name == ResultName][0]
    
    freqNumCol = ResultObj.TabularData["Mode"]
    freqCol = ResultObj.TabularData["Frequency"]
    matrix_full = [[freqNumCol[i], freqCol[i]] for i in range(len(list(freqNumCol)))]
    saveName = os.path.join(UserFilesDir, ResultObj.Name + '.csv')
    writeCSV(matrix_full,saveName)