How can I get the workbench level system ID of an analysis system from code inside Mechanical ACT?



How can I get the workbench level system ID of an analysis system from code inside Mechanical ACT?
When I try to use the system ID property of the analysis and get this warning message:
>> analysis.SystemID Obsolete Property : SystemID Property is obsolete, this gets the directory name of the current analysis, not always same as the Workbench level System ID
So how can I get the Workbench level System ID?
Answers
-
Background: Analyses in ACT has a SystemID property, however this property is the name of the directory of the analysis system files, not the system ID. Normally, these two are the same, but there are situations where they differ:
In ACT we have as far as I know only access to the directory name. However the following function get the analysis system ID:
def get_system_ID(analysis): import wbjn wb_script_format = "returnValue(filter(lambda x: x.GetComponent('Setup').DirectoryName== '{0}', GetAllSystems())[0].Name)" wb_script = wb_script_format.format(analysis.SystemID.replace(' ','-')) systemID=wbjn.ExecuteCommand(ExtAPI, wb_script) return systemID
Example usage:
analysis = ExtAPI.DataModel.AnalysisList[1] workbench_level_systemID = get_system_ID(analysis) print "Directory name: " + str(analysis.SystemID) print "System name: " + str(workbench_level_systemID)
In the example model shown earlier this prints:
Directory name: SYS 2 System name: SYS 1
Note since this function still uses SystemID, it will also show the "Obsolete Property" warning message, but the system name returned is the real one.
0