Interoperating with COM

You can access the AutoCAD Automation object model and other ObjectARX COM APIs from your .NET application.

To use AutoCAD COM APIs from .NET

  1. Create a .NET solution and project.
  2. Select Add Reference from the Project menu or Solution Explorer.
  3. On the COM tab, select the AutoCAD Type Library and the AutoCAD/ObjectDBX Common 18.0 Type Library.
  4. Add the Autodesk.AutoCAD.Interop namespace to your using or Imports statement.

You can get a pointer to a COM object from the corresponding .NET object by using the following properties from the following objects:

For example, the following C# code uses the COM application object to prompt the user for a string:

((AcadApplication)Application.AcadApplication).ActiveDocument.Utility.GetString(1, “Enter string: “);

To get the .NET object from a COM object, use the FromAcadXxx static function. For example, Database.FromAcadDatabase gets the .NET database object from the COM database object.