Chapter 5. Visual Basic for AutoCAD

Visual Basic for Applications (VBA), an extension of the popular programming language Visual Basic (VB), has been around for some time. VBA is defined as an object-oriented programming (OOP) language. The concept behind OOP is that a computer program is developed by using a collection of individual units, or objects, as opposed to a listing of instructions. Each one of the objects has the capability to receive messages, process data, and transmit messages to other objects. The objects are self-contained units that can be easily reused and modified for many purposes, thus saving time and effort.

Note

This chapter is aimed at AutoCAD users only. Sorry, AutoCAD LT users — the programming interfaces are limited to AutoCAD.VBA is part of the programming and development tools provided by Microsoft. Its origins date back to QBasic and MS-Basic, which were both introduced during and prior to the MS-DOS era. VB has been around much longer than VBA and, unlike VBA, VB can be used to build standalone applications that are not dependent on a host application.

A host application is a program that allows the VBA environment to run inside it; AutoCAD is one example. Many other popular Windows-based programs have VBA technology built into them. Some of these other applications are Autodesk Inventor, AutoCAD-based vertical products such as AutoCAD Architecture (formally known as Autodesk Architectural Desktop), and Microsoft Word and Excel.

VBA in AutoCAD has been ...

Get AutoCAD® 2009 & AutoCAD LT® 2009 All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.