Workbench script (createautomaticconnections) does not work
Erik Kostson
Member, Moderator, Employee Posts: 275
✭✭✭✭
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)
Tagged:
0
Best Answer
-
We need to run it in interactive mode. To do that, replace the last 3 lines in the script above with the following lines below, then it is fine and the contacts are generated:
system = GetSystem(Name="SYS") model = system.GetContainer(ComponentName="Model") model.Edit(Interactive=True) model.SendCommand(Language="Python", Command=cmd) model.Exit()
0