通过实体名来将实体加入到模型空间
AcDbObjectId PostToModelSpace(AcDbEntity *pEnt)
{
//打开块表
AcDbBlockTable *pBlockTable = NULL;
Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()
->getBlockTable(pBlockTable, AcDb::kForRead);
//打开块表记录
AcDbBlockTableRecord *pRc = NULL;
es = pBlockTable->getAt(ACDB_MODEL_SPACE, pRc, ZcDb::kForWrite);
pBlockTable->close();//块表记录打开后及时关闭块表
//将实体加入模块空间
AcDbObjectId entId;
es = pRc->appendZcDbEntity(entId, pEnt);
//实体加入成功后关闭块表记录和实体
pRc->close();
pEnt->close();
return entId;
}
时间: 2024-12-28 21:19:54