马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- Get A Drawing File Version Without Opening It
- Question
- I need to detect a drawing file version without loading it in the AutoCAD editor,
- how do I do it?
- Answer
- To acquire an Acad drawing file version, you can open a drawing file for reading
- using AcDbDatabase::readDwgFile() and check the file version using the
- AcDbDatabase::originalFileVersion() method. The following code snippet handles
- the version number starting from AutoCAD 2.5. Note that originalFileVersion()
- works down to AutoCAD 1.2 and MFC stock file dialog is used to provide a simple UI.
- void GetDwgVersion()
- {
- CFileDialog fileDlg(TRUE, _T("dwg"), NULL, OFN_HIDEREADONLY,
- _T("AutoCAD Drawing files (*.dwg) |*.dwg||"));
- if (IDOK != fileDlg.DoModal())
- return;
- AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue);
- Acad::ErrorStatus es = pDb->readDwgFile(fileDlg.GetPathName());
- if (es != Acad::eOk)
- {
- delete pDb;
- acutPrintf("\nCannot read drawing file.\n");
- return;
- }
- // Get the DWG version number.
- AcDb::AcDbDwgVersion dwgVer = pDb->originalFileVersion();
- switch (dwgVer)
- {
- case AcDb::kDHL_1002:
- acutPrintf("\nAutoCAD 2.5\n");
- break;
- case AcDb::kDHL_1003:
- acutPrintf("\nAutoCAD 2.6\n");
- break;
- case AcDb::kDHL_1004:
- case AcDb::kDHL_1005:
- acutPrintf("\nRelease 9\n");
- break;
- case AcDb::kDHL_1006:
- case AcDb::kDHL_1007:
- case AcDb::kDHL_1008:
- acutPrintf("\nRelease 10\n");
- break;
- case AcDb::kDHL_1009:
- case AcDb::kDHL_1010:
- case AcDb::kDHL_1011:
- acutPrintf("\nR11 and R12\n");
- break;
- case AcDb::kDHL_1012:
- acutPrintf("\nR13\n");
- break;
- case AcDb::kDHL_1013:
- acutPrintf("\nR14 (mid version).\n");
- break;
- case AcDb::kDHL_1014:
- acutPrintf("\nR14 (final version).\n");
- break;
- case AcDb::kDHL_1500:
- acutPrintf("\nR15 development (Tahoe)\n");
- break;
- case AcDb::kDHL_1015:
- acutPrintf("\nR15 final version (AutoCAD 2000 or above).\n");
- break;
- default:
- acutPrintf("\nUnknown version.\n");
- }
- delete pDb;
- }
|