AutoCAD

making the case for VBA

1 Jul, 2003 By: Barry Bowen

What 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."

-from John McIver's article,
"Visual BASIC for Applications in
IntelliCAD Part 1
"

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."

-David Stein, in
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."

-reader comment on the book
Programming AutoCAD in ObjectARX

figure
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.


AutoCAD Tips!

Lynn Allen

Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's free Tips & Tools Weekly e-newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!
Follow Lynn on Twitter Follow Lynn on Twitter


Poll
At your company, who has the most say in CAD-related software purchasing?
CAD manager
CAD users
IT personnel
vice-president/department manager
CEO/company owner
Submit Vote