|
[code]AcDbBlockTable *pBlockTable = NULL;
Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase->getBlockTable(pBlockTable, AcDb::kForRead); //得到块表指针
AcDbBlockTableRecord *pBlockTableRecord = NULL;
es = pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite); //得到块表记录指针
pBlockTable->close();
pBlockTable = NULL;
AcDbBlockTableRecordIterator *pBlockIter = NULL;
es = pBlockTableRecord->newIterator(pBlockIter);
for (pBlockIter->start(); !pBlockIter->done(); pBlockIter->step())
{
AcDbObjectId objTmpId = AcDbObjectId::kNull;
pBlockIter->getEntityId(objTmpId);
//块在模型空间中是以AcDbBlockReference存在 所以打开这个直接炸开就可以了
AcDbObjectPointer<AcDbBlockReference> pEnt(objTmpId, AcDb::kForRead);
if (pEnt.openStatus() == Acad::eOk)
{
AcDbVoidPtrArray entitySet;
es = pEnt->explode(entitySet);
if (es != Acad::eOk)
{
acutPrintf(_T("\n炸开块失败"));
}
else
{
for (int i = 0; i < entitySet.length(); i++)
{
AcDbEntity* pEnty = (AcDbEntity*)entitySet.at(i);
if (pEnty != NULL)
{
pBlockTableRecord->appendAcDbEntity(pEnty);//将炸开的实体添加到模型空间中
pEnty->close();
}
}
}
}
}
pBlockTableRecord->close();
pBlockTableRecord = NULL;
if (pBlockIter != NULL)
{
delete pBlockIter;
pBlockIter = NULL;
}[/code] |
|