As a way to get the ReferenceKey via a SelectionItem , we can leverage using a KeyPath . Below is a code snippet calling ShowPath() (instead of ShowSelectedItem() ) on a SelectionItem
while (srIterator.IsValid())
{
HPS.SelectionItem selectionItem = srIterator.GetItem();
HPS.KeyPath keyPath = new HPS.KeyPath();
selectionItem.ShowPath(out keyPath);
Key myKey = new Key(keyPath.Front());
if (myKey.Type() == HPS.Type.ReferenceKey)
{
//Add your code here;
}