AutoCAD VBA Programming: Tools and Techniques

Document Object Events

Events are functions that AutoCAD calls when something of interest to a particular object is taking place. The document object is where the majority of events take place that relate to the command system and the drawing database itself. Programming events do require that you follow specific procedures; if you are not careful, it is easy to cause AutoCAD to enter into an infinite loop meaning that the system is locked up from the user's perspective.

Let's start into events by looking at how you code an event related to the document object. Because there are specific naming requirements associated with these events, there is an easy way to access them in the VBA development editor (VBAIDE).

Event functions are defined in the ThisDrawing object. To access the code window for the event functions, take the following steps in the VBAIDE window for an active project.

  • Double click on the ThisDrawing object reference in the Projects window.

  • The code window should be displayed for the ThisDrawing object.

  • Select the left side pop-up list (objects) at the top and pick the AcadDocument choice.

  • The right side pop-up list now contains the names of the events that can be defined. Select the name of the event function you want to program and that subroutine will be started in the code window.

The names of the events cannot be changed and must be used as supplied. This is how AutoCAD knows what module to run as a particular event happens. There...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Trade Show, Conference, and Exhibition Support Services
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.