How to get automatically x y z node locations and corresponding x y z displacements?

Erik Kostson
Member, Moderator, Employee Posts: 312
✭✭✭✭
How can we read into arrays the x y z node locations and x y z displacements at these nodes?
0
Best Answer
-
There are many ways of doings this.
Two possible ways are by using mechanical scripting.
The first way is to use GetResultsData as shown here:
Readapt the above to include more directions ( displacements).
Another way is via the code shown below and at the end of this post (Readapt script to include more directions ( displacements).
We can also use DPF to do this - the following code (see link below) can be easily adapted to read displacements instead of temperatures (e.g., use dpf.operators.result.displacement_Y for y-disp).
Script mentioned above (exports and reads data back into arrays):
- analysis=ExtAPI.DataModel.Project.Model.Analyses[0]
- solution=analysis.Solution
- dirdef=solution.AddDirectionalDeformation() # add as many times as needed for x, y, z
- dirdef.NormalOrientation=NormalOrientationType.ZAxis
- solution.EvaluateAllResults()
- dirdef.ExportToTextFile("D:/dispz.csv")
- #read data in from export file above
- import csv
- nodenr=[]
- cx=[]
- cy=[]
- cz=[]
- dirdis=[]
- with open("D:/dispz.csv", 'rb') as f:
- reader = csv.reader(f)
- next(reader)
- for row in reader:
- print(row)
- nodenr.append(row[0].split('\t')[0])
- cx.append(row[0].split('\t')[1])
- cy.append(row[0].split('\t')[2])
- cz.append(row[0].split('\t')[3])
- dirdis.append(row[0].split('\t')[4])
0
This discussion has been closed.