|
//得到所有的块定义id(得到数据库中所有的块定义id)
static bool GetAllBlkDefId(AcDbObjectIdArray& arridBlkDef, AcDbDatabase* pDb /*= acdbCurDwg()*/)
{
AcDbBlockTablePointer pBlkTbl(pDb, AcDb::kForRead);
if (Acad::eOk != pBlkTbl.openStatus())
return false;
AcDbBlockTableIterator* pIt = NULL;
Acad::ErrorStatus es = pBlkTbl->newIterator(pIt);
if (Acad::eOk != es)
return false;
std::unique_ptr<AcDbBlockTableIterator> apIt(pIt);
for (apIt->start(); !apIt->done(); apIt->step())
{
AcDbBlockTableRecord* pBTRecord = NULL;
if (apIt->getRecord(pBTRecord, AcDb::kForRead) == Acad::eOk)
{
TCHAR* szName = NULL;
pBTRecord->getName(szName);
CString BlockName = szName;
if (_tcslen(szName) > 0)//过滤掉名称为空的块表;
{
if (BlockName.Find(_T("Model_Space")) == -1
&& BlockName.Find(_T("Paper_Space")) == -1
&& BlockName.Find(_T("*D")) == -1
&& BlockName.Find(_T("*U")) == -1
)
arridBlkDef.append(pBTRecord->objectId());
}
acutDelString(szName);//必须清除动态字符串;
pBTRecord->close();
}
}
return true;
} |
|