Export global coordinates of all nodes using workbench script
Hello!
I am conducting a collision experiment of two objects using explicit dynamics.
I want to export the global coordinates of all nodes of object 1 at every step through the python script below.
(At this time, LOCX selected object number 1 and used the LOC expression of the user defined result.
for step in range(steps): # steps time = aset.GetStepEndTime(step + 1) for obj in solution.Children: name = obj.Name if name == "LOCX1": obj.DisplayTime = time solution.EvaluateAllResults() X = DataModel.GetObjectsByName("LOCX1")[0].PlotData f = open(base_dir + "LOCX1_" + str(step + 1) + ".txt", mode="w") f.write("Unit : " + str(X['Values'].Unit) + "\n") for i in range(len(X['Node'])): node = X["Node"][i] # side = X["Shell Side"][i] val = X["Values"][i] f.write(str(node) + "," + str(val) + "\n") f.close()
However, when you run the post script, the same value is output as the step progresses, that is, over time, as shown below.
These values are the location values from the last step.
And when checking the graph below, we confirmed that the value of LOCX does not change over time.
What user defined result expression should I use to output the global coordinates of all nodes according to the step?
For example, use 'UX+LOC_DEFX' as the user defined result expression.
p.s. I know that mechanical has the following export option. However, the option does not seem to be applied when outputting from a script.
Comments
-
@Ansys resolved? If not, please share sample model
0