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: