THE GREYED OUT LINKS ON THE RIGHT WILL BE ACTIVATED STEP BY STEP. (SEE ALSO THE MAIN PAGE)

Saturday, August 15, 2009

My AutoLISP-Intro for Beginners

A First Thought About AutoLISP:
At first, because of a few people talking AutoLISP down and claiming that it won't be here for much more longer (maybe they are confusing it with VBA?), I want to emphasize that AutoLISP will still be around for quite some time going by what Autodesk (AutoCAD) and Bricsys (BricsCAD) related people write. It also makes sense for Autodesk and Bricsys to keep it, especially even more so since VBA really is gradually disappearing. AutoLISP is fairly easy to learn and at the same time pretty powerful. In a way the ideal environment for advanced drafters, CAD managers and the like people, who want to do some CAD programming but do not do it all the time and don't want to or can not invest into learning a more complex language like the .NET dialects or even C++. (Besides the learning curve, with these languages it also takes longer to write a program.) So, if you decide to learn AutoLISP you will still be able to use it for a long time.

The First Learning Ressource:
The first and most important learning ressource, which you should be aware of, certainly is the help file that ships with AutoCAD. The subheadings "AutoLISP, Visual LISP and DXF" as well as "ActiveX-Automation and VBA" lead to Autodesk's Developer Documentation. It is advisable to study these pages first, but it is not imperative. There also is a lot of comprehensive information available online (see the other sections of this site). You should at least, however, keep Autodesk's Documentation in mind as a reference work - it's probably most important usage.

For easier reference I put a link to the developer's help file onto my computer-desktop. You should be able to find the chm-file under this or a similar path: "C:\Program Files\AutoCAD 2010\Help\acad_dev180.chm". In AutoCAD 2008, by the way, the chm-file was called only "acad_dev.chm".

For understanding how to use ActiveX (or COM as it is also called sometimes) in AutoLISP (this i.e. includes all the vlax- and vlr-functions and others) the Developer's Documentation inside the help file offers the "AutoLISP Developer's Guide" and therein the subheading "Using the Visual LISP Environment" / "Working with ActiveX". Since this extended topic, however, is more difficult to understand for many, especially if you are completely new to ActiveX/COM, I highlighted ActiveX related words on the AutoLISP learning pages of this site, so that you can find these links more easily.

Clarifying Some Confusion Regarding AutoLISP, Visual LISP and ActiveX:
As a last thought in this intro I want to clarify what AutoLISP, Visual LISP and ActiveX is (to each other) and what it is not. (At least according to my point of view.) Unfortunately these three sometimes get a little mixed up with each other by some. Even Autodesk itself is unclear (at least to me) in it's expressions in the help file and on the website regarding this.

Basically said, AutoLISP is the programming language that provides the foundation for using the other two.

Visual LISP really is the name of the IDE (integrated development environment) in AutoCAD that you write AutoLISP code with. The IDE is, so to say, a "visual" aid because before the IDE there was nothing (provided by Autodesk). You had to write your code in a normal text editor like notepad (or buy a 3rd-party environment). In BricsCAD it is still like that. That is why there is no Visual LISP in BricsCAD, although it supports the same language with the same functions. (Side-Info: Today, the only 3rd-party-AutoLISP-Editor, that I know of, is "LispLink". In demo-mode - without a license - this program allows only 100 lines of code to be viewed and edited. Any further lines will be cut. So don't save, if you open any larger files with it! The good side is that there is no expiration date.)

ActiveX (which is also called COM by some) is really another programming interface altogether. However, at the same time when AutoCAD got it's Visual LISP IDE it also got a whole new set of functions that make use of this other ActiveX-interface. Unfortunately these set of functions is called "Visual LISP functions" or similar. (Although I prefer the term "ActiveX functions".) Why unfortunately? Because the ActiveX interface really does not have much to do with the Visual LISP IDE at all. ActiveX is also used by VBA and can be used by .NET and almost any modern programming language. ActiveX is also used by the AutoLISP in BricsCAD without the Visual LISP IDE. So now, because of this mishap it sometimes sounds as if there was a new language created called "Visual LISP", replacing "AutoLISP", which is of course NOT the case. AutoLISP is still called AutoLISP, even though it has some functions more. That happens to many programming languages all the time, that they experience some extensions but that does not change the actual name of the programming language itself.

So, you see that these three are really three different things apart from each other, although they of course use each other. (The Visual LISP IDE uses AutoLISP and AutoLISP uses ActiveX.) Just be aware, that when you read "Visual LISP", as long as it is not referring to the IDE, you may read as well "AutoLISP". If you have a different opinion, I don't want to stop you. I just want to make my statement, the way I see it.

And now have fun checking out all the links. ;)

3 comments:

iron said...

Autolisp: An insight into AutoCad Programming is well illustrated book on Autolisp programming language for beginners as well as those who have develoepd proficiency in computer programming.

Thomas Gail Haws said...

I enjoyed this article, and I like your opinions and the way you clarify the nomenclature. I do wonder why you differ from, say, Kenny Ramage (Afralisp) in your assessment of the future of VBA? Can you wax on about the demise of VBA, or are such rumors premature? Have a great day, Inspector!

Tom

Stephan Bartl said...

Thank you, Tom, for your feedback.

For one thing I want to say that I did not answer so long because I generally did not find much time to work on the blog recently.

But now I at least want to give a quick answer concerning VBA: Autodesk leaves no doubt about it that they do not want to support VBA (in AutoCAD) on the long run in the future: see here (Autodesk Developer Center -> AutoCAD -> VBA). Even though it is not clear how much longer it will be supported in the latest version of AutoCAD it nevertheless has been made public that the support will cease. Of course even then it will still be supported in the older versions and maybe in BricsCAD or maybe also in other CAD programs. But since AutoCAD is the undisputed market leader in the general CAD field, and BricsCAD as well as many other CAD programs try to imitate it, it is already clear where VBA is eventually heading towards. Therefore I think it makes sense to acknowledge this fact and start preparing for it - as long as one is/was using VBA so far.