找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 993|回复: 0

[教学]:不打开DWG文件的情况下,获得DWG文件的版本号

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-3-8 13:19:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

  1. Get A Drawing File Version Without Opening It  


  2. Question
  3. I need to detect a drawing file version without loading it in the AutoCAD editor,
  4. how do I do it?
  5. Answer
  6. To acquire an Acad drawing file version, you can open a drawing file for reading
  7. using AcDbDatabase::readDwgFile() and check the file version using the
  8. AcDbDatabase::originalFileVersion() method. The following code snippet handles
  9. the version number starting from AutoCAD 2.5. Note that originalFileVersion()
  10. works down to AutoCAD 1.2 and MFC stock file dialog is used to provide a simple UI.

  11. void GetDwgVersion()
  12. {
  13.   CFileDialog fileDlg(TRUE, _T("dwg"), NULL, OFN_HIDEREADONLY,
  14.       _T("AutoCAD Drawing files (*.dwg) |*.dwg||"));

  15.   if (IDOK != fileDlg.DoModal())
  16.     return;

  17.   AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse, Adesk::kTrue);
  18.   Acad::ErrorStatus es = pDb->readDwgFile(fileDlg.GetPathName());
  19.   if (es != Acad::eOk)
  20.   {
  21.     delete pDb;
  22.     acutPrintf("\nCannot read drawing file.\n");
  23.     return;
  24.   }

  25.   // Get the DWG version number.
  26.   AcDb::AcDbDwgVersion dwgVer = pDb->originalFileVersion();

  27.   switch (dwgVer)
  28.   {
  29.   case AcDb::kDHL_1002:
  30.     acutPrintf("\nAutoCAD 2.5\n");
  31.     break;
  32.   case AcDb::kDHL_1003:
  33.     acutPrintf("\nAutoCAD 2.6\n");
  34.     break;
  35.   case AcDb::kDHL_1004:
  36.   case AcDb::kDHL_1005:
  37.     acutPrintf("\nRelease 9\n");
  38.     break;
  39.   case AcDb::kDHL_1006:
  40.   case AcDb::kDHL_1007:
  41.   case AcDb::kDHL_1008:
  42.     acutPrintf("\nRelease 10\n");
  43.     break;
  44.   case AcDb::kDHL_1009:
  45.   case AcDb::kDHL_1010:
  46.   case AcDb::kDHL_1011:
  47.     acutPrintf("\nR11 and R12\n");
  48.     break;
  49.   case AcDb::kDHL_1012:
  50.     acutPrintf("\nR13\n");
  51.     break;
  52.   case AcDb::kDHL_1013:
  53.     acutPrintf("\nR14 (mid version).\n");
  54.     break;
  55.   case AcDb::kDHL_1014:
  56.     acutPrintf("\nR14 (final version).\n");
  57.     break;
  58.   case AcDb::kDHL_1500:
  59.     acutPrintf("\nR15 development (Tahoe)\n");
  60.     break;
  61.   case AcDb::kDHL_1015:
  62.     acutPrintf("\nR15 final version (AutoCAD 2000 or above).\n");
  63.     break;
  64.   default:
  65.     acutPrintf("\nUnknown version.\n");
  66.   }

  67.   delete pDb;
  68. }
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-16 04:14 , Processed in 0.455979 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表