How can we check the contact state and flip contact/target sides if needed?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 741
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

With Mechanical scripting, how can we check the contact state and flip contact/target sides if needed?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 741
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓

    The following function will check the contact state (well defined or unfulfilled) and flip contact/target sides if needed:

    def CheckContactState(body):
          ExtAPI.Log.WriteMessage("Checking contact status due to changing "+ str(body.Name) + "to rigid body")
          ExtAPI.DataModel.Tree.Refresh()
          contactRegions = ExtAPI.DataModel.Project.Model.GetChildren[Ansys.ACT.Automation.Mechanical.Connections.ContactRegion](True) 
          for contactRegion in contactRegions:
              if contactRegion.State==Ansys.ACT.Interfaces.Common.State.Unfulfilled :
                  contactRegion.FlipContactTarget()
          ExtAPI.DataModel.Tree.Refresh()