How can I create groups of groups for the geometry in Mechanical?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
edited June 2023 in Structures

How can I create groups of groups for the geometry in Mechanical ?

Tagged:

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    Below is a code sample to illustrate how this can be done.

    First, create a list of bodies that you would like to group:

    bodies = ExtAPI.DataModel.Project.Model.Geometry.GetChildren(DataModelObjectCategory.Body,True)
    folder1 = ExtAPI.DataModel.Tree.Group(bodies)
    folder1.Name = "My folder"
    

    Then, to place this group inside another group, the trick is to grab the folder itself and group it:

    folder2 = ExtAPI.DataModel.Tree.Group([folder1])
    folder2.Name = "My top folder"
    

    Finally, the tree has to be refreshed for the display to update:

    ExtAPI.DataModel.Tree.Refresh()

    Result is as follows:

Answers