下面是个例子,检索图中所有的OLE2FRAME对象
 - #include "dbsymtb.h" //
- #include "dbmain.h" // Entity base class
- #include "dbole.h" // OLE2 container
- void fListOle()
- {
- AcDbBlockTable *pBT = NULL;
- AcDbBlockTableRecord *pBTR = NULL;
- //get the Modelspace block table record
- acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT,AcDb::kForRead);
- pBT->getAt(ACDB_MODEL_SPACE,pBTR,AcDb::kForRead);
- pBT->close();
- //iterate the Modelspace
- AcDbBlockTableRecordIterator *pIter = NULL;
- pBTR->newIterator(pIter);
- AcDbEntity *pEnt;
- AcDbOle2Frame *pOle;
- char buf1[255];
- while(!pIter->done())
- {
- pIter->getEntity(pEnt,AcDb::kForRead);
- pOle = AcDbOle2Frame::cast(pEnt);
- if(pOle != NULL)
- {
- //LinkPath is valid only for Linked objects
- if (OT_LINK == pOle->getType())
- {
- if(TRUE == pOle->getLinkPath(buf1,sizeof(buf1))) acutPrintf("\nLink Path: %s",buf1);
- }[code=cpp]
- #include "dbsymtb.h" //
- #include "dbmain.h" // Entity base class
- #include "dbole.h" // OLE2 container
- void fListOle()
- {
- AcDbBlockTable *pBT = NULL;
- AcDbBlockTableRecord *pBTR = NULL;
- //get the Modelspace block table record
- acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT,AcDb::kForRead);
- pBT->getAt(ACDB_MODEL_SPACE,pBTR,AcDb::kForRead);
- pBT->close();
- //iterate the Modelspace
- AcDbBlockTableRecordIterator *pIter = NULL;
- pBTR->newIterator(pIter);
- AcDbEntity *pEnt;
- AcDbOle2Frame *pOle;
- char buf1[255];
- while(!pIter->done())
- {
- pIter->getEntity(pEnt,AcDb::kForRead);
- pOle = AcDbOle2Frame::cast(pEnt);
- if(pOle != NULL)
- {
- //LinkPath is valid only for Linked objects
- if (OT_LINK == pOle->getType())
- {
- if(TRUE == pOle->getLinkPath(buf1,sizeof(buf1))) acutPrintf("\nLink Path: %s",buf1);
- }
- }
- pOle->close();
- pIter->step();
- }
- //close the block table record
- pBTR->close();
- delete pIter;
- }
}
pOle->close();
pIter->step();
}
//close the block table record
pBTR->close();
delete pIter;
}
[/code]
|