Determine the version of the DXF File

Source: Internet
Author: User

Open the DXF reference manual. In the DXF reference manual, click "Index" --> enter "Header". The acadber field contains the ACD version information:

The following code uses the C language to determine the version of the DXF file:

/* ------------------------------------------------ * A small program that reads the version number of the DXF file in the header segment. * -------------------------------------------------- */# Include <stdio. h> # include <stdlib. h> # include <string. h> # include <conio. h> # define strlen 30int main (INT argc, char * argv []) {int code;/* storage group code */Char codevalue [strlen]; /* values corresponding to the storage group code */file * DXF;/* file pointer */Char filename [strlen];/* file name */Char suffix [6] = ". <G id = "1"> </G>. */printf ("Enter the file name:"); gets (filename); strcat (filename, suffix); DXF = Fopen (filename, "R");/* open the file for read Operations */If (! DXF) {printf ("An error occurred while opening the file! /N press any key to exit... "); getch (); exit (0);} else {printf (" the file has been opened. \ n reading... /n ");} while (! Feof (DXF) {fscanf (DXF, "% d", & Code); fscanf (DXF, "% s", codevalue ); if (code = 2 & strcmp (codevalue, "Header") = 0) {fscanf (DXF, "% d", & Code); fscanf (DXF, "% s", codevalue); If (strcmp (codevalue, "$ acadver") = 0) {fscanf (DXF, "% d", & Code ); fscanf (DXF, "% s", codevalue); If (strcmp (codevalue, "ac1006") = 0) {printf ("AutoCAD version: r10 .");} elseif (strcmp (codevalue, "ac1009") = 0) {printf ("AutoCAD version: R11 and R12.");} elseif (STRC MP (codevalue, "ac1012") = 0) {printf ("AutoCAD version: r13.");} elseif (strcmp (codevalue, "ac1014") = 0) {printf ("AutoCAD version: R14.");} elseif (strcmp (codevalue, "ac1015") = 0) {printf ("AutoCAD version: AutoCAD 2000. ");} elseif (strcmp (codevalue," ac1018 ") = 0) {printf (" AutoCAD version: AutoCAD 2004. ");} else {printf (" Unrecognized AutoCAD version! "); Break ;}}} fclose (DXF);/* close the file */printf (" \ n the file has been closed. "); printf (" \ npress any key to halt... "); getch (); Return 0 ;}


The effect is as follows:

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.