|  | 
 
| 整个程序主要是为了从dwg文件中得到图块的包罗矩形的两个点.(不知道有没有其他的方法) 下面怎么老是得不到 包络矩形的两个点呢?
 只会得到**Error on get the extents point...
 不知道是那里出问题了?大虾们帮忙看看吧
 //插入图形
 
 Acad::ErrorStatus es;
 CString filename="E:\\\\dwgfile\\qq.dwg";//已经存在的文件
 AcDbDatabase *pNewDb=new AcDbDatabase(Adesk::kFalse);
 es=pNewDb->readDwgFile(filename,_SH_DENYNO,false);
 if(es!=Acad::eOk)
 {
 acutPrintf("\nThe file %s cannot be opend",filename);
 return;
 }
 
 AcDbDatabase *pDb;
 pDb=acdbHostApplicationServices()->workingDatabase();
 
 CString pBlockName="testblock";
 AcDbObjectId blockID;
 
 if((es=pDb->insert(blockID, pBlockName,pNewDb,true))==Acad::eOk)
 { acutPrintf("\ninsert ok\n");
 delete pNewDb;}
 else
 { AfxMessageBox("Insert failed");
 delete pNewDb;
 return; }
 
 AcGePoint3d pt(100.0,200.0,0.0);
 AcDbBlockReference *pBlkRef = new AcDbBlockReference;
 pBlkRef->setBlockTableRecord(blockID);//指向blockId;
 pBlkRef->setPosition(pt);//设定位置
 AcDbBlockTable *pBlockTable;
 pDb->getBlockTable(pBlockTable, AcDb::kForRead);
 AcDbBlockTableRecord *pBlockTableRecord;
 pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
 pBlockTable->close();
 AcDbObjectId newEntId;
 pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef);
 pBlockTableRecord->close();
 pBlkRef->close();
 ///////取得包络矩形的两个顶点
 AcDbEntity *pEnt;
 acdbOpenAcDbEntity(pEnt,newEntId,AcDb::kForRead);
 AcDbExtents exts;
 if(pEnt->getGeomExtents(exts)!=Acad::eOk);
 {
 acutPrintf("\n**Error on get the extents point...");
 pEnt->close();
 return;
 }
 acutPrintf("\nThe maxPoint=%0.4f,%0.4f",exts.maxPoint()[X],exts.maxPoint()[Y]);
 acutPrintf("\nThe minPoint=%0.4f,%0.4f",exts.minPoint()[X],exts.minPoint()[Y]);
 pEnt->close();
 
 | 
 |