DWG Version

Discuss and ask questions about CAD .NET library.

Moderators: admin, support, SDS

DWG Version

Postby csonon » 03 Jan 2017, 13: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.
csonon
 
Posts: 2
Joined: 03 Jan 2017, 13:13

Re: DWG Version

Postby support » 05 Jan 2017, 11: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
support
 
Posts: 2673
Joined: 30 Mar 2005, 08:36

Re: DWG Version

Postby Bath » 10 Jan 2017, 08: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
Bath
 
Posts: 8
Joined: 17 Feb 2009, 17:08


Return to CAD .NET

Who is online

Users browsing this forum: Bing [Bot] and 5 guests