AutoCAD VBA Programming: Tools and Techniques

The macro system in VBA is excellent for creating small applications that solve specific problems in AutoCAD. Using VBA macros, you can greatly enhance the way AutoCAD works for a particular discipline. In this chapter we are going to explore how to keep track of the VBA macros and how to integrate them into normal AutoCAD operations. We are also going to be looking at the different ways to store VBA macros in AutoCAD drawings or as projects.
Building a complete application in VBA requires bringing together different pieces of code and dialog boxes into something the operator can initiate. It is not reasonable, or in most cases desirable, to have operators enter the VBA development system in order to start the application. Not only does this expose the application to possible changes by unqualified individuals, it also is a cumbersome way for CAD operators to interface with the system. The goal when developing an application for AutoCAD is to make the new tool integrate seamlessly into the environment. That means having the application start when someone makes a menu selection or types a command at the keyboard.
As we will see in this chapter, it's best to start an application based on VBA through the AutoCAD menu system. VBA is not well suited for the AutoCAD command line and does not provide a facility for defining new command names as in AutoLISP or ObjectARX/ADS. Only veteran AutoCAD users who learned how to draw by using...