Making a COM Connection to AutoCAD using VB.NET

Inter-process communication allows you to create dynamic workflows between software applications. This can be achieved in a variety of ways (COM, Remoting…)

The example below provides some basic code for establishing a COM connection to AutoCAD using VB.NET. After a connection is established, it is then possible to send remote commands to the AutoCAD command-line as well as automate other features in the program.

TPG_AutoCAD_COM.jpg

SEND A COMMAND

Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop

'the correct progID for AutoCAD 2010 is "AutoCAD.Application.18"

Dim progID As String = "AutoCAD.Application.18"
Dim acApp As AcadApplication

acApp = Marshal.GetActiveObject(progID)
acApp.Visible = True

' you can now send commands to the the AutoCAD command-line
acApp.ActiveDocument.SendCommand()
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License