• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Member
    Posts: 7
    Registered: ‎10-24-2012

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

    152 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. 

    Please use plain text.
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    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

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎10-24-2012

    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.

    Please use plain text.
    Active Contributor
    Posts: 42
    Registered: ‎09-05-2012

    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

     

     

     

     

    Please use plain text.
    Active Member
    Posts: 7
    Registered: ‎10-24-2012

    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!

    Please use plain text.
    *Expert Elite*
    Posts: 1,639
    Registered: ‎04-29-2006

    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
    Please use plain text.