Export Moment Reaction (Tabular Data)

Run the script to export Tabular Data from all selected Moment Reaction objects for the current design point in the current analysis. Resulting CSV file will be located in projectName\user_files.

Transparent Transparent

import csv
import wbjn

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

# Selected Moment Reaction Objects
momentReactionObjs = Tree.ActiveObjects

for momentReactionObj in momentReactionObjs:
    analysis = momentReactionObj.Parent.Parent
    resultsData=analysis.GetResultsData()
    resultSets = resultsData.ListTimeFreq
    
    wdir = analysis.WorkingDir
    dpString = wdir.split('_files')[1] # 'dpX\SYS\MECH'
    dp = dpString.split('\SY')[0]
    dp.Replace('\\','')
    
    export_path = UserFilesPath + dp +'_' + analysis.Name + '_' + momentReactionObj.Name + '.csv'
    
    X = list()
    Y = list()
    Z = list()
    Tot = list()
    vec = list()
    
    with open(export_path, 'wb') as file:
        writer = csv.writer(file)
        writer.writerow(['Moment Reaction [X]','Moment Reaction [Y]','Moment Reaction [Z]','Moment Reaction [Total]'])
        for index, i in enumerate(resultSets):
            # InternalObject - undocumented (not supported running Linux)
            X =     momentReactionObj.InternalObject.SequenceXDeformation(index)
            Y =     momentReactionObj.InternalObject.SequenceYDeformation(index)
            Z =     momentReactionObj.InternalObject.SequenceZDeformation(index)
            Tot =   momentReactionObj.InternalObject.SequenceTotalDeformation(index)
            vec.append([X,Y,Z,Tot])
        writer.writerows(vec)