Export and save stress components to a file

Erik Kostson
Member, Moderator, Employee Posts: 311
✭✭✭✭
How can we Export and save stress components (x,y,z,xy,xz,yz) to a file?
0
Comments
-
There are many ways of doing this (e.g., APDL, DPF, Mech scripting, etc.).
One way of many possible is shown here. The mechanical script below, creates these results and saves them both in separate files, and in one single file.
- solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solution
- normal_stressx = solution.AddNormalStress()
- normal_stressx.NormalOrientation = NormalOrientationType.XAxis
- normal_stressy = solution.AddNormalStress()
- normal_stressy.NormalOrientation = NormalOrientationType.YAxis
- normal_stressz = solution.AddNormalStress()
- normal_stressz.NormalOrientation = NormalOrientationType.ZAxis
- shear_stressxy = solution.AddShearStress()
- shear_stressxy.ShearOrientation=ShearOrientationType.XYPlane
- shear_stressxz = solution.AddShearStress()
- shear_stressxz.ShearOrientation=ShearOrientationType.XZPlane
- shear_stressyz = solution.AddShearStress()
- shear_stressyz.ShearOrientation=ShearOrientationType.YZPlane
- solution.EvaluateAllResults()
- ##separatefiles
- normal_stressx.ExportToTextFile("D:\mysx.txt")
- normal_stressy.ExportToTextFile("D:\mysy.txt")
- normal_stressz.ExportToTextFile("D:\mysz.txt")
- shear_stressxy.ExportToTextFile("D:\mysxy.txt")
- shear_stressxz.ExportToTextFile("D:\mysxz.txt")
- shear_stressyz.ExportToTextFile("D:\mysyz.txt")
- mysx=normal_stressx.PlotData
- ##one file
- plotDatasx= normal_stressx.PlotData.Values[2]
- plotDatasy= normal_stressy.PlotData.Values[2]
- plotDatasz= normal_stressz.PlotData.Values[2]
- plotDatasxy= shear_stressxy.PlotData.Values[2]
- plotDatasyz= shear_stressyz.PlotData.Values[2]
- plotDatasxz= shear_stressxz.PlotData.Values[2]
- nodes= normal_stressx.PlotData.Values[1]# list of node ids
- fpath = "D:/"
- fname = "mystresses.txt"
- f = open(fpath+fname,"w")
- for ii in range(0,len(nodes)):
- #print(node)
- f.write(str(nodes[ii]) +","+ str(plotDatasx[ii]) + "," + str(plotDatasy[ii]) + "," + str(plotDatasz[ii]) + ", " + str(plotDatasxy[ii])+ ", " + str(plotDatasyz[ii])+ ", " + str(plotDatasxz[ii]) +"\n")
- f.close()
0
This discussion has been closed.