TAGGED: #mechanical-#workbench
-
-
June 4, 2025 at 6:41 am
Saurabh.Prabhakar
SubscriberHi All, I have ANSYS Mechanical setup within ANSYS Workbench. I have written a python script which will be called from ANSYS Workbench to change "number of processors" in ANSYS Mechanical. For some reason, send command function for setting up "number of processors" in ANSYS Mechanical is not working properly. It is not changing the values. When I used the command using Mechanical Editor with ANSYS Mechanical window, commands work properly. Has anyone come across this issue? I am using below code to change "number of processors" in ANSYS Mechanical with ANSYS Workbench framework. *********************************************************************************************************************************************
import os###### Open Project #####Open(FilePath="/home/test.wbpj")mech_script_cmds = """config = ExtAPI.Application.SolveConfigurations["My Computer"]config.SolveProcessSettings.MaxNumberOfCores = 10"""system = GetSystem(Name="SYS")model = system.GetContainer(ComponentName="Model")model.Edit(Interactive=True)model.SendCommand(Language="Python", Command=mech_script_cmds)*************************************************************************************************Any help will be appreciated.## save project ##Save(FilePath="/home/test_f.wbpj", Overwrite=True) -
June 4, 2025 at 7:48 am
SaiD
Ansys EmployeeHello,
When I copied your script and ran it, I got an error related to indentation. So I had to correct the indentation as follows:
mech_script_cmds = """config = ExtAPI.Application.SolveConfigurations["My Computer"]config.SolveProcessSettings.MaxNumberOfCores = 8"""Once that was fixed, the script ran without any errors. Due to the "Interactive=True" command, Mechanical would open up and show the old number of cores. However, if I closed Mechanical and reopened it by double clicking on the Model cell of the Analysis System in Workbench, it would show up the correct number of cores as set in the script. So this is one workaround.The other option is to use "Interactive=False". Is there a reason why you need it to be "Interactive=True"? You could simply change it to:model.Edit(Interactive=False)This way the script will get executed without opening Mechanical, it will save a new test_f.wbpj and then if you open Mechanical, it should reflect the correct number of cores. -
June 4, 2025 at 11:18 am
Erik Kostson
Ansys EmployeeHi
See the discuss forum for scripting questions:
https://discuss.ansys.com/discussion/4402/how-to-control-number-of-cores-used-when-solving-mechanical-system-in-wb-in-batch?utm_source=community-search&utm_medium=organic-search&utm_term=How+to+control+number+of+cores+used+when+solving+Mechanical+system+in+WB+in+batch%3FAll the best
Erik
-
- You must be logged in to reply to this topic.
-
3236
-
1031
-
968
-
859
-
798
© 2025 Copyright ANSYS, Inc. All rights reserved.