admin 发表于 2024-3-14 20:23:38

[每日一码] 获得图中所有不可见的实体到AcDbObjectIdArray

/////////////////////////////////////////////////////
//get invisible entities
/////////////////////////////////////////////////////


Acad::ErrorStatus
getInvisible(const char *blkName, AcDbObjectIdArray& ents)
{
AcDbBlockTable *pBT = NULL;
    Acad::ErrorStatus es;


    if (Acad::eOk != (es=acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT, AcDb::kForRead)))
return es;


    AcDbBlockTableRecord *pBTR = NULL;


    if ( Acad::eOk != (es=pBT->getAt(blkName, pBTR, AcDb::kForRead))) {
pBT->close();
return es;
}


pBT->close();

AcDbBlockTableRecordIterator *pBTRIter = NULL;
AcDbEntity *pEnt = NULL;


for(pBTR->newIterator( pBTRIter ); !pBTRIter->done(); pBTRIter->step()) {
pBTRIter->getEntity( pEnt, AcDb::kForRead );

if (NULL != pEnt) {
   if (AcDb::kInvisible == pEnt->visibility())
    ents.append( pEnt->objectId() );


   pEnt->close();
   pEnt = NULL;
}
}
delete pBTRIter;
pBTR->close();


return Acad::eOk;
}
页: [1]
查看完整版本: [每日一码] 获得图中所有不可见的实体到AcDbObjectIdArray