objectarx 删除块定义
void DeleteBlockDefinition(AcDbDatabase* pDb, const char* blockName){
// 打开块字典
AcDbDictionary *pBlockDict;
Acad::ErrorStatus es = pDb->getSymbolTable(pBlockDict, AcDb::kForWrite);
if (es != Acad::eOk) return;
AcDbObjectId blkId;
es = pBlockDict->getAt(blockName, blkId);
if (es == Acad::eOk)
{
AcDbBlockTableRecord* pBlockRec;
es = blkId.openAcDbObject(pBlockRec, AcDb::kForWrite);
if (es == Acad::eOk)
{
// 删除块内所有实体(如果需要)
// ...
// 删除块定义
pBlockRec->erase();
pBlockRec->close();
}
}
pBlockDict->close();
}
// 示例使用
DeleteBlockDefinition(pDb, "MyBlock");
页:
[1]