|
|
VBA provides application integration with other VBA-enabled applications. This means that AutoCAD, using other application object libraries, can be an Automation controller for other applications such as Microsoft Word or Excel.
The stand-alone development editions of Visual Basic 6, which must be purchased separately, complement AutoCAD VBA with additional components such as an external database engine and report-writing capabilities.
VBA sends messages to AutoCAD by the AutoCAD ActiveX Automation Interface. AutoCAD VBA permits the Visual Basic environment to run simultaneously with AutoCAD and provides programmatic control of AutoCAD through the ActiveX Automation Interface. This linking of AutoCAD, ActiveX Automation, and VBA provides an extremely powerful interface. It not only controls AutoCAD objects, but it also sends data to or retrieves data from other applications.
The integration of VBA into AutoCAD provides an easy-to-use visual tool for customizing AutoCAD. For example, you can create an application that extracts attribute information automatically, inserts the results directly into an Excel spreadsheet, and performs any data transformations you need.
Three fundamental elements define VBA programming in AutoCAD. The first is AutoCAD itself, which has a rich set of objects that include AutoCAD entities, data, and commands. AutoCAD is an open-architecture application with multiple levels of interface. To use VBA effectively, familiarity with AutoCAD programmability is highly desirable. However, you will find that the VBA object-based approach is quite different from that of AutoLISP.
The second element is the AutoCAD ActiveX Automation Interface, which establishes messages (communication) with AutoCAD objects. Programming in VBA requires a fundamental understanding of ActiveX Automation. A description of the AutoCAD ActiveX Automation Interface can be found in the ActiveX and VBA Developer's Guide in the Help system. To display Developer Help, click Help menu Additional Resources Developer Help.
The third element that defines VBA programming is VBA itself. It has its own set of objects, keywords, constants, and so forth, that provide program flow, control, debugging, and execution. The Microsoft extensive Help system for VBA is included with AutoCAD VBA.
The AutoCAD ActiveX/VBA interface provides several advantages over other AutoCAD API environments:
- Speed. Running in-process with VBA, ActiveX applications are faster than AutoLISP applications.
- Ease of use. The programming language and development environment are easy-to-use and come installed with AutoCAD.
- Windows interoperability. ActiveX and VBA are designed to be used with other Windows applications and provide an excellent path for communication of information across applications.
- Rapid prototyping. The rapid interface development of VBA provides the perfect environment for prototyping applications, even if those applications will be developed eventually in another language.
- Programmer base. Programmers already use Visual Basic 6. AutoCAD ActiveX/VBA opens up AutoCAD customization and application development to these programmers as well as those who will learn Visual Basic 6 in the future.