objectarx 读取外部DWG图到当前图形

时间:2022-03-27 23:42:19

void CTrimeDraw::MyReadDwgFile(CString str)
{

AcDbDatabase pExternalDb(Adesk::kFalse);
 // 外部图形数据库
 if (Acad::eOk != pExternalDb.readDwgFile(str,_SH_DENYRW,false))
 {
  acedAlert(_T("读取DWG文件失败!"));
  return;
 }
 
 AcDbDatabase *pTempDb,*pData;
 if (Acad::eOk!=pExternalDb.wblock(pTempDb))
 {
  acedAlert(_T("wBlock操作失败"));
  return;
 }

pData=acdbHostApplicationServices()->workingDatabase();
 if (Acad::eOk!=pData
  ->insert(AcGeMatrix3d::kIdentity,pTempDb))
 {
  acedAlert(_T("insert 操作失败!"));
 }
 delete pTempDb;
 acdbHostApplicationServices()->setWorkingDatabase(pData);
}