I am running the below wbjn script from workbench and I think all works except of the CreateAutomaticConnections() call as no contacts are created. The same script (cmd) runs fine within mechanical scripting console.
import clr
clr.AddReference("Ansys.ACT.Core")
import Ansys.ACT.Core
appAPI = Ansys.ACT.Core.ApplicationRepository.GetApplication("Project")
ExtAPI = appAPI.GetExtensionApi(None)
cmd='''
ch=ExtAPI.DataModel.Project.Model.Connections.Children
if len(ch)>0:
for chi in ch:
chi.Delete()
else:
print("No connections")
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
connections=ExtAPI.DataModel.Project.Model.Connections
connectionsg = connections.AddConnectionGroup()
connectionsg.Name="My_Contacts"
connectionsg.ToleranceType = ContactToleranceType.Value
connectionsg.ToleranceValue = Quantity(0.11, "m")
ExtAPI.DataModel.Project.Model.Connections.CreateAutomaticConnections()
'''
system = GetSystem(Name="SYS")
model = system.GetContainer(ComponentName="Model")
model.SendCommand(Language="Python", Command=cmd)