This site is intended as a resource for extending AutoLisp (the original extension language of AutoCAD). The reason for wanting extensions to AutoLisp is that it's been "left in the dark" so to speak. Many features are simply unavailable and this makes lisp addons to AutoCAD less useful than through other methods such as ARX and DotNet. Most of the features available to VBA customizations have already been implemented through the Vital-LISP / Visual Lisp extensions, though the form designer is one which is still not available to AutoLisp except through OpenDCL / ObjectDCL (which has some compatibility problems). Also as AutoLisp was originally taken as a subset of XLisp in the mid 80's, there's many features missing which is very common in other lisp dialects.
The following sections concern various extensions to AutoLisp in order to provide more power for use in extending AutoCAD and other clones. One overruling aspect of all is that each needs to be implemented in such a way as to be as portable as possible. Thus we cannot link to ActiveX/COM anymore (as this would be unavailable for AutoCAD on Mac, and clones like BricsCAD for Linux). Also the DotNet libraries (which are the "new favorite kid" of AutoDesk) is also unavailable to AutoCAD for Mac (as well as most of the clones).
AutoLisp / VisualLisp
Some useful library functions to augment Autolisp / VisualLisp's hamstrung functionality can be found on this page: AutoLisp
AutoLisp has been left behind all other lisp dialects since the 80's. So a lot of features available to other lispers are unavailable to anyone programming in AutoLisp. The reason Common Lisp was chosen is that it's one of the most similar to AutoLisp already and thus its libraries would be the least foreign to any AutoLisper. Also it's one of the main lisp dialects and a great many lisp compilers work with either full or partial Common Lisp compatibility. Another reason is that Common Lisp is granted an ANSI standard and its libraries are extensively documented in the HyperSpec.
There are 2 options to extending AutoLisp.
Implement direct in AutoLisp
The first (and probably least difficult) is to implement the CL functions in the existing AutoLisp interpreter. Some of these functions may be extremely complex and inefficient if we stick with using only base AutoLisp functionality. Some features may simply not be available at all, e.g. Object Orientation. The Common Lisp page lists the features as per the CLHS and shows possible implementations.
Unfortunately this doesn't address the deeper problems with AutoLisp: e.g. the inability to work with all objects in AutoCAD. If such is needed then each object's properties and methods needs to be implemented individually through ObjectARX, see below.
Implement a new Embedded Common Lisp
This may be the most difficult to accomplish at first, as it's near impossible to overwrite the AutoLisp interpreter. It's built into the AutoCAD executable. Another option would be to create a secondary language implementation in AutoCAD. Something like that's already been done with the Python language: Using IronPython with AutoCAD.
The idea would be to create some functions using the normal C++ coding for ObjectARX to allow running / loading a CL script / compiled file. An open source CL implementation which is designed to be incorporated into a C program is ECL. This has the added benefit of already having the full CLHS implemented, and also allows for importing normal C++ header files - so it might work directly with ObjectARX as well.
Alternatively use Scheme
Another major dialect of lisp is called Scheme. It is still similar enough to AutoLisp to be deemed of the same family. The major difference between Scheme and Common Lisp is that Scheme is designed as simplistic as possible. Thus unlike the enormous Common Lisp library the base Scheme system is rather small in comparison. Scheme is intended to be extended through libraries written inside itself.
The ECL page documents the investigation into this route.
New functions in AutoLisp
As this has started, AutoDesk informed that they've implemented 4 new functions in AutoLisp. See this for an explanation of what these do. They've also added them into the online-help:
Further investigation needs to be done on how these perform on AutoCAD 2012 for Mac. And if these work on AEC objects, which is not available even through the ActiveX functions in VisualLisp.
Perhaps AutoDesk has not yet left AutoLisp in total darkness. Let's hope for more from them, e.g. adding method calls and event (or rather reactors) direct in AutoLisp instead of through the ActiveX connection as with VisualLisp.
ActiveX / COM
There are mostly implemented in the VitalLisp / VisualLisp examples. Unfortunately though they're not portable, e.g. they do not work on OSX. So any AutoLisp which links to the ActiveX objects of AutoCAD (never mind external programs like Excel) will fail if run on a Mac. This would probably be the same case in something like BricsCAD for Linux.
A further issue with going down this route is that AutoDesk has left the ActiveX libraries as much in the dark as it's left AutoLisp. There are various objects which are simply not part of ActiveX, especially when those comprise a vertical product's extended entity types (but also Vanilla features like Annotative Scales).
For these reasons ActiveX/COM seems seems to be a dead-end. Thus we won't be trying to extend lisp into this arena.
Similar to the ActiveX method, DotNet's got some portability issues and won't work on Mac. ADesk's mentioned that they're "working on a solution". But that was mentioned several years ago, and still no "solution" in sight. Also there's no such thing as DotNet for any of the AutoCAD clones, much less things like BricsCAD for Linux.
The DotNet libraries do however cover a much greater subset of the base ObjectARX and is deemed as the 1st port-of-call when addons need to work with newer features of AutoCAD. It is "slightly" more portable than ObjectARX as it need not be recompiled to work on different versions of AutoCAD / different types of Windows. E.g. a DotNet DLL can work with AutoCAD 2008 on Windows XP 32 bit, while it might also run smoothly in AutoCAD 2011 on Win7-64bit. Of course depending on the version of DotNet used inside the addon and the version used in AutoCAD.
For this exercise it's deemed as a last-resort, basically giving up the ghost if all else fails. To see further details regarding this investigation see the DotNet page
Currently AutoDesk has omitted much interoperability between AutoLisp and the ObjectARX SDK. These pages are meant for planning such extensions to AutoLisp as to make it work on a much greater subset of the ObjectARX libraries. To see these pages open the ObjectARX page. Note however, that it might be unnecessary if ECL is implemented.
BRX is the extension library API of the clone called BricsCAD. It is similar to AutoCAD's ARX libraries, though not compatible (at least not directly). To see further info about this, open the BRX page.
There may be other libraries which would also be useful. The Other page lists many of these.
Many resources are already available on the net. The Links page lists as many of these as possible.
So to summarize the attempt at turning AutoLisp into a full strength extension language for AutoCAD and its clones the following list of methods is sorted in order of preference:
- Overwrite the AutoLisp interpreter to something resembling Common Lisp and include links to the ObjectARX classes.
- Add a secondary interpreter such as ECL with a linking mechanism to the standard AutoLisp. Also ensure that ECL can link to the ObjectARX classes.
- Create linking functions from ObjectARX / BRX to normal AutoLisp to try and incorporate the classes in a similar way to what was done for VitalLisp / VisualLisp.
- Create such linking functions through DotNet instead. Thus tying this extension of AutoLisp to only AutoCAD for Windows, no clones and no other operating systems.
Though anyone may view these pages, you'll require membership to be able to contribute to them. If you would like to do so please join this site follow to the Join This Site page.
If you already are a member, you may also invite your friends to join this Wiki! Invite your friends