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

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 442
250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
✭✭✭✭
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: 442
    250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
    ✭✭✭✭
    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: 267
    Ansys Employee Solution Developer Community of Practice Member First Anniversary 25 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: 442
    250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
    ✭✭✭✭

    @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: 267
    Ansys Employee Solution Developer Community of Practice Member First Anniversary 25 Up Votes
    admin

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