How can I show all bodies in Mechanical through scripting?

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

How can I show all bodies in Mechanical through scripting?

Tagged:

Answers

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

    The following function can be used:

    def ShowAllBodies():
        '''
        Show all the bodies in Geometry        
        ''' 
        try:
            # log("ShowAllBodies")    
            for child in ExtAPI.DataModel.Project.Model.Geometry.Children:
                if child.DataModelObjectCategory == DataModelObjectCategory.Part:
                    child.Hidden=False            
            ExtAPI.DataModel.Tree.Refresh()
    
        except:
            ExtAPI.Log.WriteMessage("Error : Exception in ShowAllBodies()")