How can I create groups of groups for the geometry in Mechanical?
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
Best Answers
-
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:
0 -
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"
0
This discussion has been closed.