General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Export global coordinates of all nodes using workbench script

    • Bob
      Subscriber

      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.)

      1. for step in range(steps): # steps
      2. time = aset.GetStepEndTime(step + 1)
      3.  
      4. for obj in solution.Children:
      5. name = obj.Name
      6. if name == "LOCX1":
      7. obj.DisplayTime = time
      8.  
      9. solution.EvaluateAllResults()
      10.  
      11. X = DataModel.GetObjectsByName("LOCX1")[0].PlotData
      12.  
      13. f = open(base_dir + "LOCX1_" + str(step + 1) + ".txt", mode="w")
      14. f.write("Unit : " + str(X['Values'].Unit) + "\n")
      15. for i in range(len(X['Node'])):
      16. node = X["Node"][i]
      17. # side = X["Shell Side"][i]
      18. val = X["Values"][i]
      19. f.write(str(node) + "," + str(val) + "\n")
      20. 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.

    • Aniket
      Forum Moderator

      LOCX will always give the original X coordinate.

      LOC_DEFX will be deformed location X coordinate.

      -Aniket

      Forum Rules & Guidelines

    • Bob
      Subscriber

      Thank you for your advice

Viewing 2 reply threads
  • The topic ‘Export global coordinates of all nodes using workbench script’ is closed to new replies.