加载中…
个人资料
莫一剑
莫一剑
  • 博客等级:
  • 博客积分:0
  • 博客访问:1,073,262
  • 关注人气:104
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

判断dxf文件的版本

(2016-12-09 10:24:33)
分类: 图形图像及3D

打开DXF参考手册,在DXF参考手册中,点击“索引”-->输入“HEADER”,在ACADVER字段有acd的版本信息:

http://img.blog.csdn.net/20140713172924421?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FucWltYQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

     下面是用C语言,写的判断dxf文件的版本的代码:

  1.   
  2.   
  3. #include   
  4. #include   
  5. #include   
  6. #include   
  7.   
  8. #define STRLEN 30  
  9.   
  10. int main(int argc, char *argv[])  
  11.  
  12.     int  code;                    
  13.     char codevalue[STRLEN];       
  14.     FILE *dxf;                    
  15.     char filename[STRLEN];        
  16.     char suffix[6] ".dxf"          
  17.       
  18.     printf("请输入文件名:");  
  19.     gets(filename);  
  20.     strcat(filename,suffix);  
  21.       
  22.     dxf fopen(filename,"r");    
  23.     if(!dxf)  
  24.         printf("打开文件出错!/n按任意键退出...");  
  25.         getch();  
  26.         exit(0);   
  27.      
  28.     else  
  29.         printf("文件已经打开.\n正在读取.../n");   
  30.      
  31.       
  32.     while(!feof(dxf))  
  33.         fscanf(dxf,"%d",&code);  
  34.         fscanf(dxf,"%s",codevalue);  
  35.           
  36.         if(code == && strcmp(codevalue,"HEADER")==0)  
  37.             fscanf(dxf,"%d",&code);  
  38.             fscanf(dxf,"%s",codevalue);  
  39.             if(strcmp(codevalue,"$ACADVER")==0)  
  40.                 fscanf(dxf,"%d",&code);  
  41.                 fscanf(dxf,"%s",codevalue);  
  42.                   
  43.                 if(strcmp(codevalue,"AC1006")==0)  
  44.                     printf("AutoCAD版本为R10.");   
  45.                  
  46.                 else  
  47.                     if(strcmp(codevalue,"AC1009")==0)  
  48.                         printf("AutoCAD版本为R11和R12.");   
  49.                      
  50.                     else  
  51.                         if(strcmp(codevalue,"AC1012")==0)  
  52.                             printf("AutoCAD版本为R13.");   
  53.                          
  54.                         else  
  55.                             if(strcmp(codevalue,"AC1014")==0)  
  56.                                 printf("AutoCAD版本为R14.");   
  57.                              
  58.                             else  
  59.                                 if(strcmp(codevalue,"AC1015")==0)  
  60.                                     printf("AutoCAD版本为AutoCAD 2000.");   
  61.                                  
  62.                                 else  
  63.                                     if(strcmp(codevalue,"AC1018")==0)  
  64.                                         printf("AutoCAD版本为AutoCAD 2004.");   
  65.                                      
  66.                                     else  
  67.                                         printf("不能识别的AutoCAD版本!");  
  68.                                         break  
  69.                                      
  70.              
  71.          
  72.      
  73.       
  74.     fclose(dxf);                  
  75.     printf("\n文件已经关闭.");   
  76.     printf("\nPress any key to halt...");  
  77.     getch();  
  78.     return 0;  
  79.   
  80.  


效果如下:

     http://img.blog.csdn.net/20140713173640896?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FucWltYQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

注意:要把.dxf文件和代码放到同一个目录下。
dxf参考手册(中文版):http://download.csdn.net/detail/sanqima/7629929

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有