Selection クラスでは、便利な CRefArray で選択されたアイテムに Selection::GetArray 関数を使用してアクセスできます。
// C++ API
CRefArray sellist = app.GetSelection().GetArray();
LONG lSelCount = sellist.GetCount();
for (LONG i=0; i<lSelCount; i++) {
CRef currItem = sellist[i];
if ( currItem.IsValid() ) {
if ( currItem.GetClassIDName() == L"X3DObject" ) {
X3DObject x3dobj(currItem);
app.LogMessage(L"item[" + CString(i) + L"]: " + x3dobj.GetName() );
} else {
app.LogMessage(L"item[" + CString(i) + L"]: " + currItem.GetClassIDName() );
// For components this will return 'Object' which is the generic object type
}
} else {
app.LogMessage(L"item[" + CString(i) + L"] is not valid." );
}
}