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

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

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

Tagged:

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    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()  
    

Answers

  • Happy Kumar
    Happy Kumar Member Posts: 15
    First Comment
    **

    Hi Pernelle, please explain how this scripts works as I am not able see any difference in contact and target.

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    Hi @Happy Kumar , this script will reverse contact/target only if the contact is unfulfilled (blue question mark next to the contact). If it is well defined (green tick mark) it will do nothing.

  • Happy Kumar
    Happy Kumar Member Posts: 15
    First Comment
    **

    Thanks, Pernelle for your response :)