TA的每日心情![](source/plugin/dsu_paulsign/img/emot/kx.gif) | 开心 昨天 15:23 |
---|
签到天数: 69 天 [LV.6]常住居民II
管理员
- 积分
- 2704
|
void test()
{
// 得到层ID
AcDbObjectId layerId;
AcDbLayerTable *pLayerTbl = NULL;
if (acdbHostApplicationServices()->workingDatabase()
->getLayerTable(pLayerTbl, AcDb::kForRead) != Acad::eOk)
return;
if (pLayerTbl->getAt("0", layerId) != Acad::eOk)
{
pLayerTbl->close();
return;
}
pLayerTbl->close();
// 打开块表进行操作
Acad::ErrorStatus es;
AcDbBlockTable *pBlockTable = NULL;
es = acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
if (es != Acad::eOk) return;
AcDbBlockTableIterator *pBlkIter = NULL;
if (pBlockTable->newIterator(pBlkIter) != Acad::eOk)
{
pBlockTable->close();
return;
}
pBlockTable->close();
// 遍历所有块表记录,找出插入快,设置新层
AcDbBlockTableRecord *pRecord = NULL;
AcDbBlockTableRecordIterator *pRcdIter = NULL;
AcDbEntity *pEnt = NULL;
AcDbObjectIdArray Ids;
for (; !pBlkIter->done(); pBlkIter->step())
{
if (pBlkIter->getRecord(pRecord, AcDb::kForWrite) != Acad::eOk)
{
continue;
}
// 判断是否是插入块
if (pRecord->getBlockReferenceIds(Ids) != Acad::eOk || Ids.length() == 0)
{
pRecord->close();
continue;
}
if (pRecord->newIterator(pRcdIter) != Acad::eOk)
{
pRecord->close();
continue;
}
// 遍历该块表记录,设置新层
for (; !pRcdIter->done(); pRcdIter->step())
{
if (pRcdIter->getEntity(pEnt, AcDb::kForWrite) != Acad::eOk)
{
continue;
}
pEnt->setLayer(layerId);
pEnt->close();
}
delete pRcdIter;
pRcdIter = NULL;
pRecord->close();
}
delete pBlkIter;
pBlkIter = NULL;
acDocManager->sendStringToExecute(acDocManager->curDocument(), "regen ");
} |
|