Goal: Loop over all contacts in the tree and create a single named selection scoped to all of the faces.
Code:
selmgr=ExtAPI.SelectionManager
selmgr.ClearSelection()
contacts = DataModel.GetObjectsByType(DataModelObjectCategory.ContactRegion)
for contact in contacts:
selmgr.AddSelection(contact.SourceLocation)
selmgr.AddSelection(contact.TargetLocation)
total=selmgr.CurrentSelection.Ids.Count
Model.AddNamedSelection()
print "Done with macro, Create a NS with %s selections" % (total)