How to export Freq vs Acceleration data from Acceleration load from Response Spectrum Analysis?

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

How to export Freq vs Acceleration data from Acceleration load from Response Spectrum Analysis?

Comments

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

    One can use the below script to extract this data and write out a csv file. This code assumes Response Spectrum analysis is second analysis in the list. Please also be mindful of the delimiter (decimal point) used. The code assumes that delimiter is comma.

    import os
    import wbjn
    
    currAnalysis = DataModel.AnalysisList[1]
    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')
    
    LoadName = "RS Acceleration"
    
    LoadObj = [child for child in currAnalysis.Children if child.Name == LoadName][0]
    
    freqCol = LoadObj.LoadData.Inputs[0].DiscreteValues
    AcelCol = LoadObj.LoadData.Output.DiscreteValues
    matrix_full = [[freqCol[i], AcelCol[i]] for i in range(len(list(freqCol)))]
    saveName = os.path.join(UserFilesDir, LoadObj.Name + '.csv')
    writeCSV(matrix_full,saveName)