Export result data

Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 870
✭✭✭✭
Best Answer
-
The easiest way will be to use the ExportToTextFile() method, as follows:
import os export_folder = r'D:\Data' analysis = ExtAPI.DataModel.Project.Model.Analyses[0] solution = analysis.Solution total_deformation = solution.Children[1] print(total_deformation.Name) export_name = os.path.join(export_folder,total_deformation.Name) total_deformation.ExportToTextFile(export_name + '.txt')
Another option is to use the PlotData property and export the values inside it, for example to a .json file. To be dumped into a json format the data needs to be serializable, which is not the case of PlotData. However we can extract the data contained in PlotData, add it to a dictionnary, and then dump the dictionnary to the .json file, as below:
import json result_values= total_deformation.PlotData["Values"] node_list=total_deformation.PlotData["Node"] data_dict = {} for i in range(len(node_list)): data_dict[node_list[i]] = result_values[i] with open(export_name +'.json', 'w') as f: json.dump(data_dict, f)
1