I have a script that can be executed in Mechanical Scripting. How can I execute the same Mechanical script from Workbench without having an interactive Mechanical session open?
To send commands from Workbench to a Mechanical system you can use the SendCommand method which is applied to the Model cell of a System. The format of such script would be something like the below:
# User inputs system_id = 'SYS' # Mechanical System system = GetSystem(Name=system_id) model = system.GetContainer(ComponentName="Model") mechScriptCmds=""" # Commands to be executed in Mechanical Scripting here" """ model.SendCommand(Language="Python", Command=mechScriptCmds)