Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
General Mechanical

General Mechanical

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

Extract joint probes with scripting API

    • Cheyenne Hua
      Subscriber

      I have a model with some joints (bushings to ground). I have several analyses in this model, in each analysis I have some joint probes that are telling me the joint force.  I want to print the joint forces to a text file using scripting.  First I was trying to just print the joint forces to the shell.  I found this example to base my code on: https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v221/en/act_script/act_script_examples_evaluate_spring_reaction_forces.html 

      EXAMPLE: 

      # Get access to solver data
      analysis = Model.Analyses[0]
      solver_data = analysis.Solution.SolverData
      
      # Get access to result reader
      with analysis.GetResultsData() as reader:
          spring_results = reader.GetResult("SPRING")
          # Get a list of all springs
          springs = Model.Connections.GetChildren(DataModelObjectCategory.Spring, False)
      
          for spring in springs:
              print(spring.Name)
      
              spring_data = solver_data.GetObjectData(spring)
              element_id = spring_data.ElementId
      
              fForce = spring_results.GetElementValues(element_id)
              print(fForce[0])

      But it's for springs.  Trying to change it to work for bushing joints, I don't know what to put here: reader.GetResult("SPRING")  I tried "reader.GetResult("JOINT") but that does not compile.  It does run if I keep it as "SPRING" but the results are nonsense.  Please help! I could not find any documentation on the GetResult function.

      Here is my code so far:

      # Get access to solver data
      analysis = Model.Analyses[0]
      solver_data = analysis.Solution.SolverData
      # Get access to result reader
      with analysis.GetResultsData() as reader:
          joint_results = reader.GetResult("SPRING")
          # Get a list of all joints
          joints = Model.Connections.GetChildren(DataModelObjectCategory.Joint, True)
          for joint in joints:
              print(joint.Name)
              joint_data = solver_data.GetObjectData(joint)
              element_id = joint_data.ElementId
              print(element_id)
              fForce = joint_results.GetElementValues(element_id)
              print(fForce[0])

      I am using 2022 R1

    • mjmiddle
      Ansys Employee

      You can show all available solution quantities using:

      reader.ResultNames

      A bushing can be chosen as MPC or bushing formulation. The MPC type produces MPC184 element and the bushing formulation produces a COMBI250 element.

      For MPC type, you'll get these solution quantities from the bushing:

      'BOLT', 'BOLTTOOL', 'BOLT_MPC184', 'CONTAREA', 'CONTDEBOND', 'CONTFNODE', 'CONTHNODE', 'CONTPNUM', 'ELEMENTAL_REAL', 'JF', 'JFL', 'JM', 'JML', 'JOINT_ACC', 'JOINT_DOMG', 'JOINT_OMG', 'JOINT_ROT', 'JOINT_U', 'JOINT_VEL', 'JR', 'JU', 'M', 'R', 'REULER'

      Use "JF" to report the joint forces on the bushing:

      jf = reader.GetResult("JF")

      You can report the component types with jf.Components which returns ['X', 'Y', 'Z'].

      When you use jf.GetElementValues(element_id), the values will be in global coordinate system. You can compare to a joint probe set to "Total Force" except this will report in the joint reference coordinate system.

Viewing 1 reply thread
  • The topic ‘Extract joint probes with scripting API’ is closed to new replies.
[bingo_chatbox]