Author Topic: get current AutoCad version?  (Read 6099 times)

0 Members and 1 Guest are viewing this topic.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
get current AutoCad version?
« on: March 31, 2011, 04:38:18 PM »
I know we could use ACADVER to figure the version that was running, but do any acad objects indicate the version being run?
I need to know because the OriginalFileVersion property of a drawing database gives DwgVersion.Newest quite often in my experience.
My goal is to determine the version of a drawing, but it seems I must find the current acad version too.
Why that enum has Newest is beyond me, maybe OriginalFileVersion is not the right propery to look at for a drawings current version.
James Maeding

n.yuan

  • Bull Frog
  • Posts: 348
Re: get current AutoCad version?
« Reply #1 on: March 31, 2011, 05:03:54 PM »
Autodesk.AutoCAD.ApplicationServices.Application.Version

Example:

Code: [Select]
<CommandMethod("AcadVersion")> _
    Public Sub ShowAcadVersion()
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        Dim ver As System.Version = Autodesk.AutoCAD.ApplicationServices.Application.Version
        ed.WriteMessage(vbCr & "Acad Version: {0}.{1}", ver.Major, ver.Minor)
    End Sub

With my Acad2011, the command shows: Acad Version: 18.1

dan.glassman

  • Guest
Re: get current AutoCad version?
« Reply #2 on: March 31, 2011, 09:47:12 PM »
DWGVersion.Newest isn't a unique value -- it _is_ the value of the currently-running version's dwg format.  

So even though VS is showing you DWGVersion.Newest, you can do your comparisons against the 'explicit' enum members.

For example [limited to 2004-2012, but sufficient to illustrate], the following will never print "newest".  For ACAD 2010,2011,2012, it will match the DWGVersion.1024 case and print "2010", even if Visual Studio shows DWGVersion.Newest.


Code: [Select]
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;

string ver = null;
switch (db.OriginalFileVersion)
{
    case DwgVersion.AC1800:
        ver = "2004";break;
    case DwgVersion.AC1021:
        ver = "2007";break;
    case DwgVersion.AC1024:
        ver = "2010"; break;
    case DwgVersion.Newest:
        ver = "newest"; break;
    default:
        ver = "i dunno"; break;
};
ed.WriteMessage("{0}\n", ver);
« Last Edit: April 01, 2011, 10:01:34 AM by dan.glassman »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: get current AutoCad version?
« Reply #3 on: April 01, 2011, 03:04:04 AM »
2012 added new enum
Autodesk.AutoCAD.DatabaseServices.MaintenanceReleaseVersion

Just throwing it out there