Set automatic connections through scripting
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
Answers
-
The following function can be used:
def SetContacts(analysis): try: ExtAPI.Log.WriteMessage("Automation of Contacts Definition") connections = ExtAPI.DataModel.Project.Model.Connections # delete existing contacts for connection in connections.Children: if connection.DataModelObjectCategory==DataModelObjectCategory.ConnectionGroup: connection.Delete() # create automatically generated contacts contactGroup=connections.AddConnectionGroup() contactGroup.ToleranceType=0 # for slider type contactGroup.ToleranceSlider=70 # tolerance contactGroup.CreateAutomaticConnections() ExtAPI.Log.WriteMessage("End of Automation of Contacts Definition") except: ExtAPI.Log.WriteMessage("Error : Exception in SetContacts()")
4 -
We can also skip the contact group creation. The following line does everything automatically:
Model.Connections.CreateAutomaticConnections()
0