LPMODELDOC pIswModelDoc = NULL;
LPSLDWORKS pIswApp = TheApplication->GetSWApp();
HRESULT hRes;
LPMODELDOC pIswModelDocPart = NULL;
long count;
long type;
hRes = pIswApp->get_IActiveDoc( &pIswModelDocPart );
hRes = pIswModelDocPart->GetType ( &type );
if (pIswModelDocPart != NULL && type == swDocPART) {
LPPARTDOC part ;
hRes = pIswModelDocPart->QueryInterface(IID_IPartDoc,(void **)&part);
part->GetNamedEntitiesCount(&count);//将命名的实体的有关信息存入数组
LPENTITY *entities = new LPENTITY[count];
part->IGetNamedEntities(count,entities);
for(int i= 0;i < count; i++) {
VARIANT_BOOL bRetval;
entities[i]->GetType(&type);
entities[i]->Select2(false, 0, &bRetval);//高亮选中
entities[i]->Release();
}
pIswModelDocPart->Release();
}