.NET

Reply
Active Member
jasonleejackson
Posts: 7
Registered: ‎10-24-2012
Message 1 of 6 (246 Views)

Current AutoCAD Product vs. Drawing Authored Product (MEP, Arch, Vanilla, etc)

246 Views, 5 Replies
11-27-2012 09:57 AM

I am trying to find the actual product name or some other identification for the current AutoCAD product in which my .Net add-in is executing.  For example my add-in might load in 'Vanilla' AutoCAD or MEP or Architecture.  I would like to be able to detect if it is running in one of these products.  Similarly I would like to be able to detect this information from a drawing.  For example, I would like to write some logic to detect if a drawing authored in, say, MEP is being used in Architecture. 

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 2 of 6 (222 Views)

Re: Current AutoCAD Product vs. Drawing Authored Product (MEP, Arch, Vanilla, et

11-27-2012 02:41 PM in reply to: jasonleejackson

For the whole product this should do it:

 

 

Imports MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application

Dim product As String = "ACAD: " + MgdAcApplication.Version.ToString + " PROD: " + MgdAcApplication.GetSystemVariable("PRODUCT").ToString

 

in my case this says: ACAD: 19.0.0.0 PROD: AutoCAD

 

There is also object level versioning embedded in every drawing database entity (Autodesk.AutoCAD.DatabaseServices.Entity) called ObjectBirthVersion

 

 

Dim dbObj As Autodesk.AutoCAD.DatabaseServices.DBObject = _

acTrans.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)

Dim ent As Autodesk.AutoCAD.DatabaseServices.Entity = _

TryCast(dbObj, Autodesk.AutoCAD.DatabaseServices.Entity)

Dim objVersion As String = "ObjectBirthVersion: " + ent.ObjectBirthVersion.ToString

 

If you print this out:

 ObjectBirthVersion:     'AC1012,Release0'

 

http://en.wikipedia.org/wiki/.dwg#Version_history

Active Member
jasonleejackson
Posts: 7
Registered: ‎10-24-2012
Message 3 of 6 (189 Views)

Re: Current AutoCAD Product vs. Drawing Authored Product (MEP, Arch, Vanilla, et

11-30-2012 07:19 AM in reply to: sszabo

Thanks for the reply and help finding the product in the application.  I am still missing the product for the drawing.  We want to warn the user if they are opening something like a MEP drawing in vanilla AutoCAD because objects won't contain the rich data they would in MEP.

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 4 of 6 (177 Views)

Re: Current AutoCAD Product vs. Drawing Authored Product (MEP, Arch, Vanilla, et

11-30-2012 02:25 PM in reply to: jasonleejackson

You can find the drawing version info in the drawing Database under OriginalFileVersion:

 

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.OriginalFileVersion:

 

OriginalFileVersion = AC1024

 

This means: AutoCAD 2010, AutoCAD 2011, AutoCAD 2012


You can decode the version from the wiki page I linked in my original response.Not sure if this helps you but that's the only version info in the drawing I am aware of.

 

If you want to dig in yourself, the following code prints out all the available info in the drawing database.  You can use it for any object including the drawing itself:

 

Imports MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application

Dim activeDoc As Document = MgdAcApplication.DocumentManager.MdiActiveDocument

Dim ed As Editor = activeDoc.Editor

Dim props As PropertyInfo() = activeDoc.GetType().GetProperties()

ed.WriteMessage(vbLf + "PROPS=" + props.Count.ToString)

Dim i As Int32 = 0

For Each p As System.Reflection.PropertyInfo In props

    Try

       ed.WriteMessage(vbLf + p.Name + "=" + p.GetValue(activeDoc, Nothing).ToString)

       i += 1

    Catch

       Dim msgStr As String = String.Format("ERR: '{0}' p='{1}'", Err.Description, p.ToString)

       ed.WriteMessage(vbLf + msgStr)

    End Try

Next

 

 

 

 

Active Member
jasonleejackson
Posts: 7
Registered: ‎10-24-2012
Message 5 of 6 (175 Views)

Re: Current AutoCAD Product vs. Drawing Authored Product (MEP, Arch, Vanilla, et

11-30-2012 02:27 PM in reply to: sszabo

Thank you for your help.  I feel a bit embarrassed as I didn't notice the link to the wiki article.  In my defense the link looks like all the other page links so I probably just glossed it over.  Thank you for taking time to go through it!

*Expert Elite*
_gile
Posts: 2,106
Registered: ‎04-29-2006
Message 6 of 6 (157 Views)

Re: Current AutoCAD Product vs. Drawing Authored Product (MEP, Arch, Vanilla, et

12-01-2012 12:36 PM in reply to: jasonleejackson

Hi,

 

Vertical products (MEP, arch, ...) add ther own dictionaries to the NamedObjectDictionary which do not exist in Vanilla drawings. May be you can look this way...

Gilles Chanteau
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.