Export All Beam (line bodies) Forces and Moments
Run the script to export FX, MY, MZ, TQ, SFz, SFy for all beams (line bodies) in the first analysis (Analyses[0]). Resulting CSV file will be located in projectName\user_files.
import csv
import wbjn
import mech_dpf
import Ans.DataProcessing as dpf
cmd = 'returnValue(GetUserFilesDirectory())'
UserFilesPath = wbjn.ExecuteCommand(ExtAPI,cmd)
model = ExtAPI.DataModel.Project.Model
# User Input! 0 = first analysis, 1 = second analysis,..., N = analysis N
analysis = model.Analyses[0]
mesh = analysis.MeshData
geo = ExtAPI.DataModel.GeoData
beambodies=[]
for asm in geo.Assemblies:
for part in asm.Parts:
for body in part.Bodies:
if body.BodyType == GeoBodyTypeEnum.GeoBodyWire: beambodies.append(body)
dataSource = dpf.DataSources(analysis.Solution.ResultFilePath)
my_scoping = dpf.Scoping()
my_scoping.Location = 'Elemental'
data = []
for beam in beambodies:
data.append([beam.Name])
data.append(["Element Number","FX","MY","MZ","TQ","SFz","SFy"])
m = mesh.MeshRegionById(beam.Id)
elems = m.ElementIds
for enum in elems:
my_scoping.Ids = [enum]
smisc_1 = list(dpf.operators.result.mapdl.smisc(
item_index=1,
mesh_scoping=my_scoping,
data_sources=dataSource).outputs.fields_container.GetData()[0].Data)[0]
smisc_2 = list(dpf.operators.result.mapdl.smisc(
item_index=2,
mesh_scoping=my_scoping,
data_sources=dataSource).outputs.fields_container.GetData()[0].Data)[0]
smisc_3 = list(dpf.operators.result.mapdl.smisc(
item_index=3,
mesh_scoping=my_scoping,
data_sources=dataSource).outputs.fields_container.GetData()[0].Data)[0]
smisc_4 = list(dpf.operators.result.mapdl.smisc(
item_index=4,
mesh_scoping=my_scoping,
data_sources=dataSource).outputs.fields_container.GetData()[0].Data)[0]
smisc_5 = list(dpf.operators.result.mapdl.smisc(
item_index=5,
mesh_scoping=my_scoping,
data_sources=dataSource).outputs.fields_container.GetData()[0].Data)[0]
smisc_6 = list(dpf.operators.result.mapdl.smisc(
item_index=6,
mesh_scoping=my_scoping,
data_sources=dataSource).outputs.fields_container.GetData()[0].Data)[0]
data.append([enum,smisc_1,smisc_2,smisc_3,smisc_4,smisc_5,smisc_6])
with open(UserFilesPath + "\\beamForces.csv","wb") as file:
writer = csv.writer(file, delimiter=';')
writer.writerows(data)
print("Done!")