How do I get mechdb path for each Mechanical Model in WB?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 444
250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
✭✭✭✭
edited June 2023 in Structures

How do I get **mechdb **path for each Mechanical Model in WB Console? Ideally a mapping of each Mechanical model to its respective **mechdb **file.

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 444
    250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
    ✭✭✭✭
    Answer ✓

    This code will give you a dictionary of all WB Mechanical systems mapped to their respective mechdbs.

    from collections import defaultdict
    all_systems = [system.ToString().Split(":")[-1] for system in GetAllSystems()]
    
    all_mech_dbs = defaultdict(list)
    for system_name in all_systems:
        all_mech_dbs[system_name].append(filter(lambda x: ("%s.mechdb" % system_name.Replace(" ", "-") == x.Split("\")[-1]), GetAllFiles()))