General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

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

    • Bob
      Subscriber
      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)
    • Aniket
      Forum Moderator

      so if you copy-paste the content of the post_script.py to the cmd variable does it work as expected?

      -Aniket

      Forum Rules & Guidelines

Viewing 1 reply thread
  • The topic ‘Workbench script (SendCommand: send python script) does not work’ is closed to new replies.