Script for deleting selected workbench systems.

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 732
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

Script for deleting selected workbench systems.

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 732
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

    The below script works at the project page level.

    #Enter the systems to be deleted
    systems2Delete = ["C","D"]
    
    from collections import defaultdict
    systemsData = defaultdict(list)
    systems = GetAllSystems()
    for system in systems:
        component1 = system.Components[0]
        systemsData[ACT.InitializeAndGenerateTaskCoordinates(component1)[0]] = system
    #Sorting is required since after every delete systems get re-named
    #Therefore deleting the systems in reverse order
    sortedValues = systemsData.keys()
    sortedValues.sort()
    sortedValues.reverse()
    from collections import OrderedDict
    OrderedData  = OrderedDict()
    for value in sortedValues:
        OrderedData[value] = systemsData[value]
    
    for key in OrderedData:
        if key in systems2Delete:
            OrderedData[key].Delete()