Export Force Reaction (Tabular Data)

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

Transparent Transparent Transparent

import csv
import wbjn

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

# Selected Force Reaction Objects
forceReactionObjs = Tree.ActiveObjects

for forceReactionObj in forceReactionObjs:
    analysis = forceReactionObj.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 + '_' + forceReactionObj.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(['Force Reaction [X]','Force Reaction [Y]','Force Reaction [Z]','Force Reaction [Total]'])
        for index, i in enumerate(resultSets):
            # InternalObject - undocumented (not supported running Linux)
            X =     forceReactionObj.InternalObject.SequenceXDeformation(index)
            Y =     forceReactionObj.InternalObject.SequenceYDeformation(index)
            Z =     forceReactionObj.InternalObject.SequenceZDeformation(index)
            Tot =   forceReactionObj.InternalObject.SequenceTotalDeformation(index)
            vec.append([X,Y,Z,Tot])
        writer.writerows(vec)