www.mxdraw.com
|
数据库的块表记录类型,所有可见实体都会放到块表记录中用于显示
class McDbBlockTableRecord : public McDbSymbolTableRecord;
McDbSymbolTable.h
例如:遍历图所有实体信息,并修改实体的颜色
void ModifyAllEntity() { // 下面读取图中指定块的属性。 McDbBlockTableRecordPointer spBlkRec(MCDB_MODEL_SPACE, acdbCurDwg(),McDb::kForRead); if(spBlkRec.openStatus() != Mcad::eOk) { return; } // 生成遍历数据库用的遍历器. McDbBlockTableRecordIterator* pIterator = NULL; spBlkRec->newIterator(pIterator); if(pIterator == NULL) return; std::auto_ptr<McDbBlockTableRecordIterator> spIter(pIterator); // 遍历数据库 for(;!pIterator->done();pIterator->step() ) { McDbObjectId id; pIterator->getEntityId(id); McDbObjectPointer<AcDbEntity> spEntity(id,McDb::kForWrite); if(spEntity.openStatus() != Mcad::eOk) continue; spEntity->setColorIndex(MrxDbgUtils::kWhite); if(McDbLine::cast(spEntity.object()) != NULL) { // 是个直线实体 McDbLine* pLine = McDbLine::cast(spEntity.object()); } else if(McDbArc::cast(spEntity.object()) != NULL) { // 是个圆弧实体 McDbArc* pArc = McDbArc::cast(spEntity.object()); } else if(McDbText::cast(spEntity.object()) != NULL) { // 是个文字实体 McDbText* pText = McDbText::cast(spEntity.object()); } /* else if... ... */ } }