How to run a workbench journal file on already existing wbpj via Matlab ?

44 次查看(过去 30 天)
Hi.
I have work on optimization work. I am adjusting new input value according to output of before design points.
I have a already existing wbpj and wbjn. Each wbjn file is generated based on the previous, analysis results.
Wbjn files are work fine when i run manually. But i want run with system or dos command in matlab platform.
When i write,
system('C:\"Program Files"\"ANSYS Inc"\v212\Framework\bin\Win64\RunWB2.exe -B')
Opening new window and i can not control.

回答(3 个)

Abhinaya Kennedy
Abhinaya Kennedy 2023-10-11
Hello Tarik,
I understand you want to run the ANSYS Workbench (WB) in batch mode using the system or dos command in MATLAB without opening a new window. You can modify the command to run in the background. Here's an example:
system('start /B "" "C:\Program Files\ANSYS Inc\v212\Framework\bin\Win64\RunWB2.exe" -B')
In this modified command, the "start /B" option is used to run the command in the background without opening a new window. The " " is included as a placeholder for the window title. Make sure to adjust the file path to match the location of the "RunWB2.exe" file on your system.
By using this modified command, you should be able to run ANSYS Workbench in batch mode from MATLAB without opening a new window, allowing you to control the execution programmatically.
Hope this helps!

子君 郑
子君 郑 2023-11-8
编辑:子君 郑 2023-11-8
you can add "-R yourmacro.wpjn" to the command line so that the macro runs automatically after WB starts.

SorMun
SorMun 2023-11-16
Hi Tarik,
after you install the addon, check the the pdf included in the toolbox, for the instructions to start Workbench in server mode, connect it to Matlab and then issue scripting commands from Matlab
Add the following to the standard Workbench command to start it in server mode:
-I -E "with open('<WB_aaS_key>','w') as file:file.write(Server.StartServer('<host_name>',0,<start_port_range>,<end_port_range>))"
WB_aaS_key is just the file name to store connection information to a text file
host_name is the machine name or IP address where Workbench is running . You can use localhost if both of them (Matlab and Workbench) are running on the same.
start_port_range, end_port range define range of ports. Workbench will pick one that is available to listen for Matlab requests
Once you have Workbench started, you can copy the generated WB_aaS_key file to the Matlab machine and execute the following commands to connect. If the WB_aaS key is 'wb_aas_key.txt' this will be the code that you will write to retrieve the contents of the Workbench Schematic
load_ansys_aas
actwbserver('wb_aas_key.txt'')
execwbcommand('systems=GetAllSystems()'))
char(querywbvariable(‘systems’))
Once connected yyou can execute:
execwbcommand - to execute any legal scripting Workbench command
querywbvariable - to retrieve the value of any scripting variable in Worbench
Please let me know if you have additional questions
Sorin

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by