DWG Version

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
csonon
Posts: 2
Joined: 03 Jan 2017, 15:13

DWG Version

Post by csonon » 03 Jan 2017, 15:16

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.

support
Posts: 3253
Joined: 30 Mar 2005, 11:36
Contact:

Re: DWG Version

Post by support » 05 Jan 2017, 13:40

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Bath
Posts: 22
Joined: 17 Feb 2009, 19:08

Re: DWG Version

Post by Bath » 10 Jan 2017, 10:48

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

Post Reply