Should You Learn to Program AutoCAD? Yes! (Harry's Code Class Newsletter)
25 Aug, 2008AutoCAD users can dip their toes in customization or dive in head-first. Time and effort required may vary, but every approach pays off.
When you are first learning AutoCAD or moving to a new level of expertise or changing job responsibilities, it is not unusual to question the value of programming. After all, if you are an AutoCAD user, your job is to produce drawings, not to make programs. Sometimes CAD managers are responsible for creating programs to improve workflow and quality. And in rare cases, a company will hire a programmer to automate some aspect of its work. But if you?re not a CAD manager or a professional programmer -- that is, you are an AutoCAD user -- should you learn to program AutoCAD?
I think this is a pretty simple question to answer: Yes, learn to program. However, there?s more to the answer than a simple yes or no.
What Exactly is Programming?
First off, understand that AutoCAD can be customized using a variety of programming techniques that vary in complexity. Object links programming is the most complex, followed by macro languages, menu customization, and custom graphics.
Custom graphics. When you define a block, you are defining a custom graphic -- the easiest type of AutoCAD programming. Adding the block to a library of blocks takes that programming up a level. The next step up in custom graphics is to define a custom linetype. Another step up the ladder would be creating a custom hatch pattern or shape set. Most programmers are quite satisfied with learning to create block libraries because they represent the best return on investment for the minimum time spent.
Menu customization. Menus in AutoCAD include programmed buttons and pop-up (or pull-down) menus used to launch commands, reference variables, and invoke expressions. AutoCAD menu customization also varies in complexity. At the simplest level it involves creating command sequences.
Incorporating variables and simple expressions in a routine is the next step and involves more advanced programming, which begins to move us to the next level of macro languages.
Macro languages. A macro is a custom command sequence you create to do your work for you, such as a program to draw a page outline and insert a proper title block based on data input by the user. Macro languages for customizing AutoCAD include Visual LISP (the current iteration of the long-standing AutoLISP language), VBA (Visual BASIC for Applications), and Object ARX.
Professional programmers may prefer to use the Object ARX language to create custom AutoCAD macros because it is based on Microsoft's Visual Studio (and other professional programming languages), whereas CAD managers are advised to stick with the tried-and-true Visual LISP and VBA so their work can move from one version of AutoCAD to the next with minimal maintenance. Given AutoLISP?s legacy, the majority of existing AutoCAD customization macros are written in Visual LISP. (Cadalyst's new CAD Tips site contains far more AutoLISP-based tips than any other kind.) Those newer to the AutoCAD game but who have a bit of programming background may find VBA programming more to their liking. VBA programming also can be applied to Microsoft-related products and can be a valuable tool for integrating multiple applications, such as a Microsoft Excel spreadsheet and the CAD system.
Keep in mind that macro language programming works only with full AutoCAD and its various professional versions, not with AutoCAD LT.
Object-level programming. Object-level programming is the most complex for an AutoCAD user because you must know how to program in a language that can exploit objects. The preferred tool is Microsoft?s Visual Studio and the C# language. However, any language that can interface with object libraries in Windows can interface with AutoCAD. That includes VBA, VB, C++, Java, Pearl, and a host of other languages professional programmers may prefer.
What Level of Programming?
So now that we?ve qualified the more simple question, let?s drill down a bit further. The next question -- one that?s worth pondering -- is whether you should learn to program at the macro language level. That is a big step to take for people who have never learned to program. Even if you have some programming background, chances are pretty good you didn?t learn LISP, and the prospect can be daunting.
Begin by asking yourself where you stand in the learning-to-program food chain. Have you ever picked up a sample program, read it, kind of understood it, made a change or two? If so, you are a programmer.
Typically, the first foray into programming might be to adjust some constant value embedded in the code. Next, you might try to include more output. As you confront the need for increasingly complex changes and modifications, you could spend time learning how to accomplish and master specific tasks. It can take a long time to advance from beginning to master programmer.
Designing custom programs offers significant advantages. You can improve productivity by reducing the time required to draw common elements. You can improve drawing quality by enforcing layer and linetype rules. You can improve morale by providing operators with tools they request. But before you can do any of that, you need to learn how to program at the macro language level.
Is it worthwhile for AutoCAD operators to learn macro language programming? Again, I?d answer yes. The ability to program AutoCAD, even just a little, moves you out of the confines of your software box and into a wide open universe that is limited only by your imagination. The only way to find out if you have the aptitude for programming is to try. Just don't expect your boss to be ready to pay for you to learn. For most users, learning to program AutoCAD needs to be an extracurricular activity.
Where to Begin
Learning the craft of programming in AutoCAD need not be too time-consuming, depending on your approach and aptitude for such things. Many people prefer to learn by examining code created by others. Learning from examples works for a lot of people; however, this approach does tend to miss some of the fundamentals. Reading online tutorials and help files is another way to learn. Several books are devoted to the subject that can get you moving further along the path. Less common these days but still available in some areas are programming classes at a nearby tech school.
For the AutoCAD operator, learning to program AutoCAD macro languages will require some personal effort. Your employer may be willing to allow some tinkering time if the job load is light, but don?t expect it to be granted when the demand for your time is high. That?s why a new term was invented back in the 1980s to describe the act of programming when you are supposed to be drawing: PUDDER (Programming Under Deliberately Difficult Environmental Restrictions). ?Pudderin?? became a useful way to answer the boss when asked what you were doing for a precious period of potentially billable time. The boss would interpret this to mean you were fixing the tool.
So, until next time, keep on pudderin?.
Related Resources- Cadalyst AutoCAD Tutorials
- Cadalyst CAD Tips Site
- The Ultimate AutoLISP Tutorial, by Jeffery P. Sanders