How can I link Analysis System Index in Mechanical to it's corresponding System Index on the Project

Options
Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 419
5 Likes First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

How can I link Analysis System Index in Mechanical to it's corresponding System Index on the Project page?

For multiple systems / mechanical sessions of the project page the SYS- is incremented by 1 each time a system is created, based on the time is created. How do I get the SYS- and Analysis index mapping in Mechanical Session.

enter image description here

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 419
    5 Likes First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    I don't think there is a direct link between the SYS- and Analysis index from an analysis in Mechanical, because SYS - IDs increment by 1 each time a system is created, SYS- are given to systems in the order of their creation time (SYS, SYS-1, SYS-2…), but the indexes start from zero for every Mechanical session (as shown in the screenshot). One can however, use the result file path to build a workaround.

    The following code will give a dictionary - SYSTEM_ANALYSIS_LINK_DICT, which contains the mapping of SYS-ID with the analysis index.

    Note: Please change "file.rst" in the regex expression as per analysis type.

    SYSTEM_ANALYSIS_LINK_DICT = {}
    import re
    my_regex_expression = r"(.*)\MECH\file.rst"
    
    for index, analysis in enumerate(ExtAPI.DataModel.AnalysisList):
        system_directory = re.search(my_regex_expression, analysis.Solution.ResultFilePath)
        system_string = system_directory.group(1).Split("\")[-1]
        SYSTEM_ANALYSIS_LINK_DICT.update({system_string: index})
    
  • Vishnu
    Vishnu Member, Employee Posts: 214
    Name Dropper First Anniversary Solution Developer Community of Practice Member First Comment
    Answer ✓
    Options

    You can as well get the WB system name like below

    analysis1 = ExtAPI.DataModel.Project.Model.Analyses[0]
    WBSystemName = analysis1.WorkingDir.split("\")[-3]