Rename a Named Selection Based on Scoping

Code Purpose:

When executed, the example code shown below automatically identifies the Named Selections objects in the Outline and renames them based on the scoping specified in the Geometry Selection property. This code renames the existing Named Selections using the number of geometric entities or mesh entities included in the scoping as well as the entity type. For example: 5 Bodies, 1 Face, 75 Elements.

Example Code:

named_selections = DataModel.GetObjectsByType(DataModelObjectCategory.NamedSelection)

print named_selections.Count

for named_selection in named_selections:
    named_selection.Name = named_selection.PropertyByName('GeometrySelection').StringValue

print "Done renaming!"

Illustrated Example

Before ScriptAfter Script