Page 1 of 1

DWG Version

Posted: 03 Jan 2017, 15:16
by csonon
Is there a method/way to get the version a .dwg file was last saved in?
I see GetDWGVersion but this consistently returns a value of 1.

Re: DWG Version

Posted: 05 Jan 2017, 13:40
by support
Hello Chris,

You can determine the DWG version using a CADImage.Converter.HeadStruct.Version field which returns a byte type value for different DWG versions:
  • 0 - DWG R9 (AC1004)
    1 - DWG R10 (AC1006)
    2 - DWG R11 (AC1009)
    3 - DWG R12 (AC1009)
    4 - DWG R13 (AC1012)
    5 - DWG R14 (AC1014)
    6 - DWG 2000 (AC1015)
    7 - DWG 2004 (AC1018)
    8 - DWG 2007 (AC1021)
    9 - DWG 2010 (AC1024)
    10 - DWG 2013 (AC1027)
CADConverter.GetDWGVersion method returns the same byte type values for the internal DWG version (AC####). If the AC#### code is specified incorrectly, the method returns a value of 1. Below is an example of using the GetDWGVersion method:

Code: Select all

byte version = cadImage.Converter.GetDWGVersion("AC1027");
Mikhail

Re: DWG Version

Posted: 10 Jan 2017, 10:48
by Bath
You can get AC#### code directly from dwg file by reading first six bytes :

Code: Select all

Function GetDwgVersion(ByVal sFileName As String) As String
        Dim strVersion As String = ""
        Using reader As New System.IO.BinaryReader(File.Open(sFileName, FileMode.Open, FileAccess.Read))
            Dim bt() As Byte = reader.ReadBytes(6)
            strVersion = System.Text.ASCIIEncoding.ASCII.GetString(bt)
            reader.Close()
        End Using
        GetDwgVersion = strVersion
    End Function