About Developing Applications With ActiveX Automation

ActiveX Automation is a technology developed by Microsoft® and is based on the COM (component object model) architecture. You can use it to extend AutoCAD-based products, share your drawing data with other applications, and automate tasks.

You can create and manipulate drawing objects from any application that serves as an Automation controller. Thus, Automation enables macro programming across applications, a capability that normally isn't available for use with AutoLISP. For example, you might want to prompt for input, set preferences, make a selection set, or retrieve drawing data.

The displayed objects are called Automation objects. Automation objects make methods, properties, and events available. Methods are functions that perform an action on an object. Properties are functions that set or return information about the state of an object. Events are user-initiated actions or occurrences to which a program responds.

Note:
  • ActiveX automation in AutoCAD LT for Windows is limited to the AutoCAD ActiveX library and the AutoLISP programming language only; AutoCAD LT does not support ActiveX automation with VBA or other programming languages. There is also no support for third-party ActiveX libraries, such as those used to access Microsoft Word and Microsoft Excel. You must have AutoCAD or an AutoCAD-based product to take full advantage ActiveX automation.
  • ActiveX automation is not supported on Mac OS or Web.

Access External Applications with ActiveX (AutoCAD for Windows Only)

The advantage of implementing an ActiveX interface for the program is two-fold:

Virtually any type of application can access the exposed Automation objects within AutoCAD. These applications can be stand-alone executables, dynamic linked library (DLL) files, and macros within applications such as Microsoft Word or Microsoft Excel. The most common of these is likely to be a stand-alone executable. If you are using applications from third-party developers, follow their instructions for installation and use of their product.

Define an External Command to Start Your Application (AutoCAD for Windows Only)

You can use the acad.pgp file to define a command that runs an external command to start a stand-alone application; similar to that of a command alias which can be used to start a command.

The following example defines the RUNAPP1 command, which executes app1.exe from the c:\vbapps\ directory. (Add this code to the external commands section of your acad.pgp file.)

RUNAPP1, start c:\vbapps\app1, 0

If your application requires command line parameters, you can use the following code:

RUNAPP2, start c:\vbapps\app2, 0, *Parameters: ,

This example defines the RUNAPP2 command, which prompts you for parameters and then passes them to your application.

Tip: You can also use the AutoLISP startapp function to start an application that makes use of Automation. Once AutoLISP starts the external application, it has no control over its actions. You can, however, use AutoLISP to locate and run different applications based on certain parameters.

Start an Application from the User Interface (AutoCAD for Windows Only)

After defining an external command to start a stand-alone application, you can use that command as part of a command macro from a user interface element.

If you use only one or two applications, you can add them to one of the standard ribbon panels or the Quick Access toolbar. If you have a group of applications, you can define your own ribbon panels that are specifically dedicated to those applications.