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 Tips & Tricks Tuesdays free e-newsletter and we'll notify you every time a new video tip is available. All exclusively from Cadalyst!
Follow Lynn on Twitter Follow Lynn on Twitter


Latest News from Cadalyst Partners
Feed
Autodesk FormIt 4.0 & Dynamo Announced at AIA 2013   19 Jun, 2013

Autodesk’s free conceptual tool for the ipad, Autodesk FormIt was just updated as version 4. FormIt is the 1st Architectural Form Modeler for the...More>>Read all Between the Lines blog posts>>

Feed
Producing Cool Millions with PTC   19 Jun, 2013

The equipment in China’s restaurant kitchens is much like that everywhere else– stainless steel refrigerators, cold workstations, ice...More>>Read more PTC Creo blog posts>>

Feed
Update 3 now available for Revit 2013 Products - Revit Clinic   18 Jun, 2013

...More>>Read more BIMbuilder blog posts>>

Feed
SolidWorks customer Signatech helps give new life to Alpine racing at Le Mans   19 Jun, 2013

Living in France, I have always been fascinated by the yearly 24 Hours of Le Mans race, which began in 1923 and is the world’s oldest active sports...More>>Read more SolidWorks Blog posts>>

Feed
EngineerVsDesigner: E72 – Mark Setrakian of Robot Combat League   19 Jun, 2013

What does it take to design and build giant robots that fight each other to total destruction in four...More>>Read more SolidSmack blog posts>>

Poll
How many years' experience do you have using CAD software?
Less than two years
2–5 years
6–10 years
11–20 years
21+ years
Submit Vote




FREE Resources for CAD, BIM, and PLM Users





Subscribe Cadalyst Newsletters