.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

5 REPLIES 5
Reply
Message 1 of 6
jasonleejackson
510 Views, 5 Replies

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

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. 

5 REPLIES 5
Message 2 of 6
sszabo
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

Message 3 of 6
jasonleejackson
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.

Message 4 of 6
sszabo
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

 

 

 

 

Message 5 of 6
jasonleejackson
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!

Message 6 of 6
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost