Is it possible in Ansys Mechanical scripting to find all contacts between bodies assigned to two specific materials (e.g., Steel and Aluminum) and highlight those contacts automatically?
Here is a short script that can do this -
# Target materials (change these as needed) mat1 = "copper" mat2 = "aluminum" # Build body name to material lookup body_mats = {b.Name: b.Material for b in Model.Geometry.GetChildren(DataModelObjectCategory.Body, True)} # Find matching contacts matches = [] for contact in Model.Connections.GetChildren(DataModelObjectCategory.ContactRegion, True): c_mat = (body_mats.get(contact.ContactBodies) or "").lower() t_mat = (body_mats.get(contact.TargetBodies) or "").lower() if (mat1 in c_mat and mat2 in t_mat) or (mat2 in c_mat and mat1 in t_mat): matches.append(contact) # Highlight all matching contacts if matches: Tree.Activate(matches)