In Mechanical how to rename analysis based on names in Workbench ?
Hi,
In Workbench, I renamed my analysis.
In Mechanical, I have to rename all the analysis.
Is there a way with a Python script (or other) to automaticly rename analysis in Mechanical, based on names in Workbench ?
Thanks,
Jean
Best Answer
-
@Jean , just realized there's actually a simpler way to do that. Below code should be executed from Mechanical.
analyses = ExtAPI.DataModel.AnalysisList for an in analyses: an.Name = an.SystemCaption
2
Answers
-
Hi,
I reused this post: https://discuss.ansys.com/discussion/2478/how-do-i-communicate-with-the-project-page-from-within-mechanical to come up with the following code, to be executed from Mechanical, and which will rename the analyses both at the Project Schematic level and in Mechanical.
Note - there is no direct link in this code between the component in the project schematic and the Mechanical analysis, it is assumed the analyses systems will be looped in the same order. Please verify it works correctly on your model.import System from System.Threading import * def RunWBJN(cmds): def Internal_RunWBJN(): import wbjn wbjn.ExecuteCommand(ExtAPI,cmds) thread = System.Threading.Thread(System.Threading.ThreadStart(Internal_RunWBJN)) thread.Start() project_cmds = ''' systems = GetAllSystems() for i, sys in enumerate(systems): sys.DisplayText = "Test_"+str(i) ''' RunWBJN(project_cmds) analyses = ExtAPI.DataModel.AnalysisList for i,an in enumerate(analyses): an.Name = "Test_"+str(i)
0 -
Hi,
Thanks for your answer.Unfortunately, it's not what I expected.
In this code, names in Workbench are replaced by "test_i".
(Since there is no link between Workbench and Mechanical, I get some problem when the project is more "complex", as shown in images below (test_5 in Workbench is test_0 in Mechanical))My goal is :
(i) get names in Workbench (I don't want to rename system, but getting names I already gave) ;
(ii) rename system in Mechanical with name from Workbench.Thanks
Jean0 -
@Landon Mitchell Kanner , I thought you had something like this... can you comment on this topic?
0 -
Thanks a lot, it's perfect!
1 -
Glad I could help! Still wondering why I went for a convulted solution in the first place
0