获得指定数据库中指定块表中所有实体的id
该函数也使用外部指定图纸中的数据库中的块
Int getIdsByDwgBlkName(AcDbDatabase *pDwg, CString strBlkName, AcDbObjectIdArray &objIds)
{
//打开指定块定义的块表记录
AcDbBlockTable *pBlkTbl = NULL;
pDwg->getBlockTable(pBlkTbl, AcDb::kForRead);
AcDbBlockTableRecord* pBlkTblRcd;
Acad::ErrorStatus es = pBlkTbl->getAt(strBlkName,pBlkTblRcd,AcDb::kForRead);
pBlkTbl->close();
if (es!=Acad::eOk)
{
return RTNONE;
}
//遍历块表记录中的实体
AcDbBlockTableRecordIterator* pItr;
pBlkTblRcd->newIterator(pItr);
AcDbEntity* pEnt = NULL;
for(pItr->start();!pItr->done();pItr->step())
{
Acad::ErrorStatus es = pItr->getEntity(pEnt,AcDb::kForWrite);
if(Acad::eOk == es)
{
//将实体Id加入到Id数组中
objIds.append(pEnt->objectId());
}
pEnt->close();
}
delete pItr;
pBlkTblRcd->close();
return RTNORM;
}