making the case for VBA
30 Jun, 2003 By: Barry BowenWhat programming language should you learn?
Should I learn AutoLISP, ObjectARX, or VBA (Visual BASIC for Applications)? I hear this question often from users who want to go beyond custom toolbars and menu macros. Which one is best? That depends on whom you ask. Many articles available on the Internet explain why you should choose VBA over AutoLISP, or vice versa.
VBA VIRTUES VS. AUTOLISP
"Most development in these programs is performed using LISP in IntelliCAD (AutoLISP in AutoCAD), an interpretive programming language that offers great flexibility. The biggest drawback to LISP is that it's slow. If substantial data processing is required, it can take a lot of time to complete. Also, to implement any form of dialog box requires interfacing with the DCL system, and this can be quite messy."
A VOTE FOR VISUAL LISP
"Visual LISP is more than simply a replacement for AutoLISP . . . . But the most significant changes to the language itself are due to the addition of ActiveX interface functionality. This effectively puts Visual LISP potential on par with other ActiveX technologies such as VBA. While Visual LISP still lacks many of the sophisticated tools VBA has, it does possess the capability to interface with ActiveX providers and consumers such as Microsoft Office, Microsoft Windows, and even AutoCAD itself, in ways not possible with AutoLISP."
The Visual LISP Developers Bible
OBJECTARX ADVANTAGES
"There are very good reasons to do ObjectARX programming, most of which have to do with the ability to add your own custom classes to the AutoCAD object model and
create your own entity types from scratch. If you don't need to do that yet, go get a beginning Visual C11/MFC (Microsoft Foundation Classes) book. In the meantime, VBA is extremely fast for all but the most demanding applications and is worth very careful study."
Programming AutoCAD in ObjectARX
![]() Figure 1. The VBA IDE (integrated development environment) is similar across all software applications that incorporate it. |
VERDICT
Though ObjectARX may be the most powerful and advanced API (application programming interface), it's not for the casual or part-time programmer. If we limit this discussion to AutoCAD only, I could make a very convincing case for Visual LISP, but I think there is a much bigger picture here that you should consider.
True, you find a LISP interface in other programs such as IntelliCAD, PowerCAD, and TurboCAD. However, the VBA programming language appears in a much wider base of CAD programs, and it's also included in a number of Microsoft Windows applications. The latter to me is perhaps the most important reason for learning VBA. It gives you the ability to go beyond CAD should you choose a different occupation in the future. Who knows, you may change companies and end up where MicroStation is the main CAD software. But you'll be prepared to immediately put your VBA skills to use.
For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX. Visit the Equipped Mold Designer here!
For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP. Visit the Equipped Architect here!