You can use selection filter in OdDbSelectionSet query to exclude unnecessary entities from result selection set:
Code:
/** \details
Filter selection only.
\param vpId [in] id of OdDbViewportTableRecord record or OdDbViewport entity in which to select.
\param nPoints [in] Number of points into selection shape.
\param wcsPts [in] Selection shape as set of World Coordinate Space points.
\param mode [in] Selection mode.
\param sm [in] Subentities selection mode.
\param pFilter [in] object of type OdDbSelectionFilter or pointer to a OdResBuf chain defining the filter.
*/
static OdDbSelectionSetPtr select(
const OdDbObjectId& vpId,
int nPoints,
const OdGePoint3d* wcsPts,
OdDbVisualSelection::Mode mode = OdDbVisualSelection::kCrossing,
OdUInt32 sm = OdDbVisualSelection::kDisableSubents,
const OdRxObject* pFilter = 0);