General Mechanical

General Mechanical

Workbench from command line – leave application open

Tagged: ,

    • langlinator
      Subscriber
      I am running Workbench from Python via Windows Command Line. The command opens Workbench, a specific workbench project, and runs a specific workbench script. My Python script does this iteratively, using and updating an external dataset.nWhen opening Ansys from command line, there is a delay of around 10-15 seconds while the application is opening. At least I think it is - it prints ....\student.lic exists. three times, every time, before executing the script.nMy question is this: Is there a way that I can leave Workbench open, but close the project, to eliminate the time required to load the Workbench application every time?n
    • Aniket
      Ansys Employee
      If I understand this correctly you have a script and you want to run it multiple times (with or without changed parameter) in same workbench session, so you can just loop it in the script itself?nJust create a single script that does as follows:nopen workbenchnopen projectnrun script Ansave filenrun script BnSave filenwill that help?n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • langlinator
      Subscriber
      Hi,nThe process isnOpen workbenchnOpen skeleton project (everything defined except material and some parameters for direct optimization)nRun script (gathers material data from CSV files, defines parameters for direct optimization).Note, this script is updated by my Python script, so is not the same every time.nRun direct optimizationnSave certain result to CSVnPython reads result, updates material data CSV files and workbench script --> Repeat (various things are happening in my Python script, this is a simplification).nIf I could just leave workbench open, it would save time. The workbench project is NOT saved at the end of the script, and is opened again in its skeleton each iteration. I'm wondering if there is a modifier on the windows command for this.n
    • Aniket
      Ansys Employee
      Oh do you mean you want to keep Mechanical open? Because I see whenever you have skeleton project the workbench window is already open and not being closed.nIf that is correct, for parametric updates, workbench always closes all the applications including Mechanical for parameter updating process, if that is not what you mean, kindly explain it bit further?n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • langlinator
      Subscriber
      Hi, thanks for the response. Using my script, workbench closes each time I run it from command line. The ideal solution would be to close the skeleton project (without saving) - hence closing mechanical too ; but leave workbench application open (with no project open). I then send the command again, and it opens up the skeleton project again, but without the delay associated with starting workbench.nThe command I send via Windows Command Line is:nC:\Program Files\ANSYS Inc\ANSYS Student\v201\Framework\bin\Win64\runwb2.bat -B -F [skeleton project path].wbpj -R [workbench script path].wbjnn
    • Aniket
      Ansys Employee
      Please do not use skeleton project opening arguments in the command line, instead record that operation manually File>Scripting>Record and add it to start of your workbench script!n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • langlinator
      Subscriber
      Hi AniketnSo, if Workbench is already opened, what command should I call to prevent a second instance of Workbench being opened?nI was thinking the command may look like this:nC:\Program Files\ANSYS Inc\ANSYS Student\v201\Framework\bin\Win64\runwb2.bat -B  -R [workbench script path].wbjnnBut that may open a second instance of Workbench (I haven't had time to test this yet).nn
    • Aniket
      Ansys Employee
      you are right and the workbench wbjn will include the skeleton project opening commands. Those can be recorded as explained in the journal.n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • langlinator
      Subscriber
      For anyone reading this, I did not find a way to leave workbench open, and to open/close projects from commandline. It does not appear to be possible at this time.n
    • Aniket
      Ansys Employee
      Your workflow is:nopen workbenchnopen skeleton projectnmodify skeleton projectnsave some data (csv) from modified skeleton project (Not the project)nagain open the skeleton project that was opened in step 2nreiterate step 3 and 4nto transition from step 4 to step step 5 you will need to reopen the skeleton project which needs clearing existing data of modified skeleton project and opening original project. If you can reiterate with modified skeleton project, you would not need to reopen the skeleton project.n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • langlinator
      Subscriber
      Hi AniketnI tried this, and didn't get it to work. I wasn't able to send further commands to Ansys/Workbench via commandline until it was closed.n
Viewing 10 reply threads
  • You must be logged in to reply to this topic.