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

Options
Jonas Norlin
Jonas Norlin Member, Employee Posts: 14
First Anniversary Ansys Employee Solution Developer Community of Practice Member
✭✭✭
edited June 13 in Structures

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?

Tagged:

Answers

  • Jonas Norlin
    Jonas Norlin Member, Employee Posts: 14
    First Anniversary Ansys Employee Solution Developer Community of Practice Member
    ✭✭✭
    Answer ✓

    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:

    System ID

    Directory name

    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.