Trying to read data from a DWG using Autodesk.AutoCAD.DatabaseService What DLL do I need to reference to?

3.8k views Asked by At

I have a VB winform project where I am reading data from a table inside a DWG file. By this method AutoCad needs to be open(making the application slower).

I found the article show below where you can use a different approach where you use a Database object(represent our in-memory drawing) But I don't know what DLL do I need to reference to be able to use this method. The method use on this appraoch is :

using Autodesk.AutoCAD.DatabaseServices; --> need to be able to import

And also the article is from 2006 and on C#. Is there a Better approach now a days ?

Thanks in advance

Breaking it down-A closernLook at the C# code for importing blocks

2

There are 2 answers

0
Ognyan Dimitrov On
  1. AcDbMgd.dll which stands for "AutoCAD Database Managed" and inside of it are the objects for DWG (aka Database) manipulation.
  2. AcMgd.dll which stands for "AutoCAD Managed" and inside of it are the objects with which you can get the Database objects of the current active DWG.
  3. Set "Copy Local" to False because AutoCAD carries its own copies of the same DLLs.

You can get the DLLS from ObjectArx Libraries which are here. When you install them there will be the dlls you need.

Look at AutoCAD`s Developers Guide examples and explanations for the latest "How to".

3
Augusto Goncalves On

If you create a .DLL that you load inside AutoCAD (with NETLOAD command or with PackageContents.xml/.bundle folder), then you need the following references from AutoCAD install folder:

  1. AcMgd.dll
  2. AcDbMgd.dll
  3. AcCoreMgd.dll (this is required on AutoCAD 2013 and newer)

And make sure all the references are set as Copy Local = false, note this is important :-)

You may have problems with .NET version, so make sure that you have:

  • .NET 3.5 for AutoCAD 2010+
  • .NET 4.0 for AutoCAD 2012+
  • .NET 4.5 for AutoCAD 2015+

And if you choose a older version of .NET, the compiler may throw erros, like cannot use the references. If you are starting, please check at http://www.autodesk.com/myfirstautocadplugin

Now, if you have a external application (.exe), then you cannot use the above, but only the COM references (also from AutoCAD install folder)

  1. Autodesk.AutoCAD.Interop.dll
  2. Autodesk.AutoCAD.Interop.Common.dll

But for these COM interop you have a different data-model and also a different namespace. Also, this is deprecated, meaning no new features to it.