- 积分
- 289
- 明经币
- 个
- 注册时间
- 2004-8-19
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
//创建一个空白的图形数据库 //注意该处AcDbDatabase()函数的参数必须为Adesk::kFalse AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); //将指定文件名的图形A件读入到空白的B形数据库中 const char* sFileName="c:\\AA.dwg"; Acad::ErrorStatus es=pNewDb->readDwgFile(sFileName , _SH_DENYNO,false); if (es!=Acad::eOk) { acutPrintf("\nThe file %s cannot be opend",sFileName); return; } //获得块表指针 AcDbBlockTable *pBlockTable; pNewDb->getSymbolTable(pBlockTable, AcDb::kForRead); //获得模型空间的块农记录指针 AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead); pBlockTable->close(); //生成块表的迭代器 AcDbBlockTableRecordIterator *pIterator; pBlockTableRecord->newIterator(pIterator); AcGePoint3d basePoint; AcDbEntity *pEnt; AcDbMText *pAttdef; char temp[200]; int i; i=0; for (pIterator->start(); !pIterator->done(); pIterator->step())//将source.dwg中所有的Attibute进行遍历 { i++; itoa(i,temp,10);/// // acutPrintf(temp); pIterator->getEntity(pEnt, AcDb::kForRead); if (pEnt->isKindOf(AcDbMText::desc())) { // acutPrintf("第% AcDbMText ",i); // acutPrintf("\n\n"); pAttdef = AcDbMText::cast(pEnt); if ( !( pAttdef->contents()==NULL) ) { acutPrintf(" AcDbMText: %s \n" ,pAttdef->contents()); 获取坐标 // basePoint = pAttdef->position(); // acutPrintf(" AcDbMText: %Ld %Ld %Ld\n" // ,basePoint->X(),basePoint->Y(),basePoint->Z()); } } pEnt->close(); // use pEnt... pAttdef might be NULL }; delete pIterator; } |
|