How to check if the Analysis System in WB contains a particular component?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 389
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited December 2022 in General Language Questions

How to check if the Analysis System in WB contains a particular component? For example check if Analysis System "example" contains "Results":

enter image description here

enter image description here

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 389
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Answer ✓

    The System object has all the components in the Attribute Components. You can use the following code:

    # Get the relevant system
    system = GetAllSystems()[2]
    # Filter out the results component
    result_component = filter(lambda x: ("Results" in x.Name), system.Components)
    
    # If not present the list is empty
    if result_component:
        print("Yes the component is there!")
    else:
        print("Sorry the component is missing!")
    
  • James Derrick
    James Derrick Administrator, Employee Posts: 242
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Up Votes
    admin

    I don't fully understand your question. Would you mind elaborating a bit in it? E.g. It's not clear how the image relates to the example you give.

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 389
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

    @James Derrick: Actually it is pretty straightforward. The rows in the analysis system are components. The question is to check if the analysis system contains a certain component for example the "Result" row. Modified some pictures, is it clear now?

  • James Derrick
    James Derrick Administrator, Employee Posts: 242
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Up Votes
    admin

    I was thinking less for me and more for potential future readers, if that makes sense?