About Accessing the AutoCAD Application Object (AutoLISP/ActiveX)

The Application object is the root object for the AutoCAD object model.

Note: ActiveX support in AutoLISP is limited to Windows only.

From the Application object, you can access any of the other objects, or the properties or methods assigned to objects. Before you can use ActiveX functions with AutoLISP, you need to load the supporting code that enables these functions. The following function call enables ActiveX support:

(vl-load-com)

This function first checks if ActiveX support is already loaded; if so, the function does nothing. If ActiveX support is not already loaded, vl-load-com loads the ActiveX support and other extension functions for the AutoLISP language.

Note: All applications that use ActiveX should begin by calling vl-load-com. If your application does not call vl-load-com, the application will fail, unless another program has already loaded the ActiveX support functions.

After loading the ActiveX support functions, the first step in accessing AutoCAD objects is to establish a connection to the AutoCAD Application object. Use the vlax-get-acad-object function to establish this connection, as in the following example:

(setq acadObject (vlax-get-acad-object))

The vlax-get-acad-object function returns a pointer to the AutoCAD Application object.

In the example above, the pointer is stored in the acadObject variable. This return value exists as a unique Visual LISP data type called VLA-object (Visual LISP ActiveX object).

When you refer to AutoCAD objects with ActiveX functions, you must specify a VLA-object type. For this reason, you cannot use entget to access an object and then refer to that object with an ActiveX function. The entget function returns an object of data type ename. Although you cannot use this object directly with an ActiveX function, you can convert it to a VLA-object using the vlax-ename->vla-object function.