Send commands inside commands (wbjn inside mechanical)
Erik Kostson
Member, Employee Posts: 233
✭✭✭✭
The below code is trying to send commands via system A (SYS) and its Mechanical scripting console and into another system (say system B / SYS 1), but does not work. It is due to the wbcmd string that seems ok formatted but still does not work. Any help is much appreciated.
import System from System.Threading import * def RunWBJN(cmds): def Internal_RunWBJN(): import wbjn wbjn.ExecuteCommand(ExtAPI,cmds) thread = System.Threading.Thread(System.Threading.ThreadStart(Internal_RunWBJN)) thread.Start() wbcmd = ''' system2 = GetAllSystems()[1] system2.DisplayText = "my name17" model2 = system2.GetContainer(ComponentName="Model") mcmd=""" f=ExtAPI.DataModel.Project.Model.Analyses[0].AddForce() """ model2.SendCommand(Language="Python", Command=mcmd) ''' RunWBJN(wbcmd)
0
Best Answer
-
Just took away a line in the mcmd string and it works. SO the above is ok, but we need to have Mechanical UI of System B (and any other system of interest) open.
0
Answers
-
Some extended code also:
my=Tree.FirstActiveObject.GetType() import System from System.Threading import * def RunWBJN(cmds): def Internal_RunWBJN(): import wbjn wbjn.ExecuteCommand(ExtAPI,cmds) thread = System.Threading.Thread(System.Threading.ThreadStart(Internal_RunWBJN)) thread.Start() s = ''' system2 = GetAllSystems()[1] system2.DisplayText = "my name21" model2 = system2.GetContainer(ComponentName="Model") mcmd=""" f=ExtAPI.DataModel.Project.Model.Analyses[0].AddForce() Tree.Refresh() """ model2.SendCommand(Language="Python", Command=mcmd) Tree.Refresh() ''' d = ''' system2 = GetAllSystems()[1] system2.DisplayText = "my name21" model2 = system2.GetContainer(ComponentName="Model") mcmd=""" f=ExtAPI.DataModel.Project.Model.Analyses[0].AddFixedSupport() Tree.Refresh() """ model2.SendCommand(Language="Python", Command=mcmd) Tree.Refresh() ''' if my.FullName == 'Ansys.ACT.Automation.Mechanical.BoundaryConditions.Force': RunWBJN(s) elif my.FullName == 'Ansys.ACT.Automation.Mechanical.BoundaryConditions.FixedSupport': RunWBJN(d) else: print('No force or fixed support is selected')
0
This discussion has been closed.