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 December 2 in Structures

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

Tagged:

Best Answers

  • 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:

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 276
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited December 2 Answer ✓

    To add, say we have 2 springs and want to add them to a folder:

    spt=[]
    spt.append(ExtAPI.DataModel.GetObjectsByName("Longitudinal - Ground To Sup")[0])
    spt.append(ExtAPI.DataModel.GetObjectsByName("Torsional (Beta) - Ground To Sup")[0])
    folder1 = ExtAPI.DataModel.Tree.Group(spt)
    folder1.Name = "My_springs"
    
This discussion has been closed.