Microsoft Visual Studio can utilize both native .NET and COM interfaces in the same project. By utilizing COM interop, you can migrate existing code that might have been written in Visual Basic 6 or VBA without having to completely rewrite it. To access the AutoCAD automation objects from a project created in Microsoft Visual Studio, create references to the following files:
These references will make the following primary interop assemblies available:
The interop assemblies are located in the global assembly cache; they map automation objects to their .NET counterparts.
After you reference the type libraries, you can declare AutoCAD-based variables in Microsoft Visual Studio, as in the following examples:
Dim objAcApp As Autodesk.AutoCAD.Interop.AcadApplication Dim objLine As Autodesk.AutoCAD.Interop.Common.AcadLine
Autodesk.AutoCAD.Interop.AcadApplication objAcApp; Autodesk.AutoCAD.Interop.Common.AcadLine objLine;
Utilizing the interop assemblies can make the transitioning your VBA projects over to VB.NET much easier. However, in order to take full advantage of everything that .NET and the AutoCAD .NET API have to offer, you will need to rewrite your existing VBA code.
AutoCAD .NET applications can utilize the same type library (acax20enu.tlb) as AutoCAD automation projects. The type library is located in <drive>:\Program Files\Common Files\Autodesk Shared.
AutoCAD .NET applications also use the same version-dependent ProgID for the CreateObject, GetObject, and GetInterfaceObject functions.
You can use the product ProgID to create a new instance of the AutoCAD application ("AutoCAD.Application"), and specify the major and minor number of the release to restrict your application to a specific release or all the releases that are binary compatible with each other.
For example,
If you are using ActiveX/COM from an in-process DLL (Class Library) and want to reference the AutoCAD application object, you can use Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication property.