Checking DWG Version with VBA - Error Handling

Checking DWG Version with VBA - Error Handling

Anonymous
Not applicable
233 Views
3 Replies
Message 1 of 4

Checking DWG Version with VBA - Error Handling

Anonymous
Not applicable
Hi all,

Is ther a way in the R14 object model to determine what version the
currently opened DWG file is saved in? Is there anything in the R15 object
model. I have looked around in both? Perhaps there is something at the
AutoLisp level which can determine this for me.

I have built a utiltiy which can batch through 100's and 100's of drawings.
This utility was written in VB using the R14 object model. The only problem
is if a drawing which has been saved in the R15 file format is part of the
batch it will trip up the utility because R14 cannot open this file format.

Does anyone have any suggestions on how to handle this error?

Thanks a bunch!
Shane
0 Likes
234 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
There is nothing in the R14 Object Model that can determine the version of
an ACAD drawing file. You need to use the "Open file For Input Access Read
As #1" statement to open the drawing file and read the first six (6)
characters of the file. These characters are different for every version of
AutoCAD. All 2000 files begin with "AC1015", R14 with "AC1014", and R13
with "AC1012".
Once you have this information you can use a conditional statement to load
the file or ignore it.

Hope this helps.

TM Amick II
Jacobs Engineering Group

Shane Moorhead wrote in message
news:7vnic7$oah27@adesknews2.autodesk.com...
> Hi all,
>
> Is ther a way in the R14 object model to determine what version the
> currently opened DWG file is saved in? Is there anything in the R15
object
> model. I have looked around in both? Perhaps there is something at the
> AutoLisp level which can determine this for me.
>
> I have built a utiltiy which can batch through 100's and 100's of
drawings.
> This utility was written in VB using the R14 object model. The only
problem
> is if a drawing which has been saved in the R15 file format is part of the
> batch it will trip up the utility because R14 cannot open this file
format.
>
> Does anyone have any suggestions on how to handle this error?
>
> Thanks a bunch!
> Shane
>
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks, I will give it a whirl
Shane

TM Amick II wrote in message
news:7vq4dl$19s24@adesknews2.autodesk.com...
> There is nothing in the R14 Object Model that can determine the version of
> an ACAD drawing file. You need to use the "Open file For Input Access
Read
> As #1" statement to open the drawing file and read the first six (6)
> characters of the file. These characters are different for every version
of
> AutoCAD. All 2000 files begin with "AC1015", R14 with "AC1014", and R13
> with "AC1012".
> Once you have this information you can use a conditional statement to load
> the file or ignore it.
>
> Hope this helps.
>
> TM Amick II
> Jacobs Engineering Group
>
>
> Shane Moorhead wrote in message
> news:7vnic7$oah27@adesknews2.autodesk.com...
> > Hi all,
> >
> > Is ther a way in the R14 object model to determine what version the
> > currently opened DWG file is saved in? Is there anything in the R15
> object
> > model. I have looked around in both? Perhaps there is something at the
> > AutoLisp level which can determine this for me.
> >
> > I have built a utiltiy which can batch through 100's and 100's of
> drawings.
> > This utility was written in VB using the R14 object model. The only
> problem
> > is if a drawing which has been saved in the R15 file format is part of
the
> > batch it will trip up the utility because R14 cannot open this file
> format.
> >
> > Does anyone have any suggestions on how to handle this error?
> >
> > Thanks a bunch!
> > Shane
> >
> >
>
>
0 Likes
Message 4 of 4

Philipp_Becher
Participant
Participant

Public Function dwg_Version(Datei) As String 'returns the version of the DWG
If Datei = "" Then Exit Function
Open Datei For Input Access Read As #1
Line Input #1, Line
dwg_Version = Left$(Line, 6)
Close #1
If dwg_Version = "AC1032" Then dwg_Version = "AutoCAD 2018" '13.12.2017
If dwg_Version = "AC1027" Then dwg_Version = "AutoCAD 2014"
If dwg_Version = "AC1024" Then dwg_Version = "AutoCAD 2011"
If dwg_Version = "AC1021" Then dwg_Version = "AutoCAD 2007/2008/2009?"
If dwg_Version = "AC1018" Then dwg_Version = "AutoCAD 2004/2005/2006"
If dwg_Version = "AC1015" Then dwg_Version = "AutoCAD 2000/200i/2002"
If dwg_Version = "AC1014" Then dwg_Version = "AutoCAD 14"
If dwg_Version = "AC1012" Then dwg_Version = "AutoCAD 13"
If dwg_Version = "AC1009" Then dwg_Version = "AutoCAD 11,12"
If dwg_Version = "AC1006" Then dwg_Version = "AutoCAD 10"
If dwg_Version = "AC1004" Then dwg_Version = "AutoCAD 9"
If dwg_Version = "AC1002" Then dwg_Version = "AutoCAD 2.6"
End Function

0 Likes