Identify bodies in named selections and make dedicated named selections for each
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 859
✭✭✭✭
I would like to have named selections for each body from given named selection, how can this be achieved through scripting?
Tagged:
0
Answers
-
The following code can be used:
named_selections=ExtAPI.DataModel.Project.Model.NamedSelections # reference Named Selection section in the tree main_NS = ExtAPI.DataModel.GetObjectsByName("main_NS")[0] # Get NS called "main_NS" for bodyId in main_NS.Ids: # loop on bodies in main_NS new_NS = named_selections.AddNamedSelection() # create new NS new_NS.Name = "new_NS_object_" + str(bodyId) # change name of NS temp_sel=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) # define a temporary selection temp_sel.Ids = [bodyId] # set Ids for temporary selection new_NS.Location = temp_sel # assign temporary selection
0