How to rename a Static Structural Analysis in WB based on its name in the Mechanical?
Let's say I have three analyses connected together sharing the same model. In Ansys Mechanical I changed manually the names to "Static A" "Static B" and "Static C".
How to automatically update these names in Workbench to not have the usual "Copy of Copy of Copy"? Is it possible to connect Workbench and Mechanical with some scripting?
Thanks!
Best Regards,
Dominique
Answers
-
I wrote a blog on this topic here. Here is the relevant portion:
If we want to make modifications to the Project Page, we need to interact with the Project Page on a separate thread from Mechanical. Here is an example to change the name of a system in the Project Page from within Mechanical:
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 = ''' system1 = GetAllSystems()[0] system1.DisplayText = "my name" ''' RunWBJN(project_cmds)
0 -
In addition to the commands shared by @Landon Mitchell Kanner , here's how in Mechanical you can loop on all the analyses and rename them:
for i,analysis in enumerate (ExtAPI.DataModel.Project.Model.Analyses): analysis.Name = "My renamed analysis number " + str(i)
1 -
Thank you @Landon Mitchell Kanner. It partially solved my issue meaning I can match now "Results File Directory" with my "Static A" analysis. Thanks a lot!
However I have a situation where my 'System ID' and my 'Results ID' / 'Directory Name' don't match and I cannot access 'SYSTEM ID' of a Static Structural Object from the Mechanical.
I couldn't find anything simple like "ExtAPI.DataModel.AnalysisList[0].[GET_SYSTEM_ID]" or GetSystem("search by Results ID 'SYS-84'")
I guess I'll have to reverse my approach and send the data from WB to Mechanical instead.
0 -
Here is one workaround, but it assumes that analysis blocks have unique display names:
def GetProjectSystemID(sysname): import wbjn global cmdStat cmds = """ def GetSystemNameByDisplayText(SchematicName): AllSys=GetAllSystems() for sys in AllSys: if sys.DisplayText==SchematicName: return sys.Name return None name = GetSystemNameByDisplayText("%s") returnValue(name) """%(sysname) cmdStat=wbjn.ExecuteCommand(ExtAPI, cmds) return cmdStat SysID= GetProjectSystemID(ExtAPI.DataModel.AnalysisList[0].SystemCaption) print SysID
1