With Mechanical scripting, how can we check the contact state and flip contact/target sides if needed?
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()
Hi Pernelle, please explain how this scripts works as I am not able see any difference in contact and target.
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.
Thanks, Pernelle for your response