Export Min/Max Tabular Data
This code exports Min/Max Tabular Data for Deformation Z results created on the named selection ‘MYBODY’ to the path C:\temp\test_dpf_tabular_data.csv.
def after_post(this, solution):# Do not edit this line
import os
import csv
import mech_dpf
import Ans.DataProcessing as dpf
analysis = Model.Analyses[0]
dataSource = dpf.DataSources(analysis.Solution.ResultFilePath)
#Time list
timelistDataIn = dpf.operators.metadata.time_freq_provider(data_sources = dataSource)
timelistData = timelistDataIn.outputs.time_freq_support.GetData()
timelist = timelistData.TimeFreqs.Data
ns_op=dpf.operators.scoping.on_named_selection()
ns_op.inputs.requested_location.Connect('Nodal')
ns_op.inputs.named_selection_name.Connect('MYBODY')
ns_op.inputs.data_sources.Connect(dataSource)
myMesh = ns_op.outputs.mesh_scoping.GetData()
def_values = []
for index,time in enumerate(timelist):
data = []
dispfieldIn = dpf.operators.result.displacement_Z()
dispfieldIn.inputs.time_scoping.Connect(time)
dispfieldIn.inputs.data_sources.Connect(dataSource)
dispfieldIn.inputs.mesh_scoping.Connect(myMesh)
dispfieldOut = dispfieldIn.outputs.fields_container.GetData()# fields_container
minmaxFieldsContainer= dpf.operators.min_max.min_max_fc()
minmaxFieldsContainer.inputs.fields_container.Connect(dispfieldOut)
mini = minmaxFieldsContainer.outputs.field_min.GetData().Data[0]
maxi = minmaxFieldsContainer.outputs.field_max.GetData().Data[0]
if index == 0:
data.append('Min')
data.append('Max')
def_values.append(data)
data = []
data.append(mini)
data.append(maxi)
def_values.append(data)
with open("C:\\temp\\test_dpf_tabular_data" ".csv", 'wb') as csv_file:
writer = csv.writer(csv_file, delimiter=';')
writer.writerows(def_values)