Workbench script (SendCommand: send python script to model) does not work

Options
Ansys hardworker
Ansys hardworker Member Posts: 3
edited April 6 in Structures

Hello!

I am running the wbjn script from workbench. The rest runs well, but it appears that ‘post_script.py’ is not being imported to the model, as ‘post_script.py’ is not executed. So, I think it’s probably a problem with ‘Model_exp.SendCommand’. Can I ask for advice on the cause?

encoding: utf-8

2021 R2

SetScriptVersion(Version="21.2.209")

sys_exp = GetSystem(Name="SYS")
sys_imp = GetSystem(Name="SYS 1")

CleanSystem(Systems=[sys_exp])
CleanSystem(Systems=[sys_imp])

designPoint1 = Parameters.GetDesignPoint(Name="0")
designPoint1.SetParameterExpression(Parameter=Parameters.GetParameter(Name="P10"),Expression="10 [degree]")
designPoint1.SetParameterExpression(Parameter=Parameters.GetParameter(Name="P11"),Expression="10 [mm]")

Model_exp = sys_exp.GetContainer(ComponentName="Model")
Model_exp.Edit(Hidden=False)

Update() # Solving

script = open("post_script.py", "r")
cmd = script.read()
script.close()

Model_exp.SendCommand(Language="Python", Command=cmd)