Python Extension for Autocad/Intellicad
Autocad/Intellicad Extension for Python
This Project has the goal to make Python available as a scripting language for the CAD programs Autocad and Intellicad.
Autocad currently has APIs for several languages, including C, C++, Lisp (though Autolisp is much simpler than the standard Common Lisp), VBA (through COM), and Java (officially through COM, but a direct interface is available through activities similar to this project). Theoretically, the COM interface would make any COM aware language (including Python) capable of talking to Autocad, but in practise this approach has shown to be unreliable.
Intellicad shares a subset of the Lisp and C APIs with Autocad, and a VBA extension is available as well. The parts of the Autocad ADS C API that pyacad uses are completely present in Intellicad (named SDS there), so that we are able to expose exactly the same functionality for both programs.
Pyacad is currently in the state of "mostly implemented".
Changes from release 0.3 to 0.4.1.
The project has two aspects:
Make the Python interpreter available for Autocad/Intellicad.
Pyacad embeds a Python interpreter into a running Autocad/Intellicad drawing session as an ADS/ARX/SDS based module, which is loaded as a DLL (>=R13/Ic2000) or as a seperate application with IPC (<=R12).
Make Autocad/Intellicad functions available for Python.
The extension makes a builtin module "_ads" available to the Python interpreter. This is the core of the Autocad/Intellicad interface for Python and is intended to wrap the complete ADS/SDS C API. For a Python program, an ads module (written in Python) wraps this core, and provides additional services, besides exposing the core functionality. In order to keep the underlying CAD system transparent to Python programs, we have chosen to stay with the module names "_ads" and "ads", even when actually connecting to Intellicad through the SDS library.
The fourth round of results fulfils almost all my own needs. If you're interesting in trying Pyacad, you can download the sources here and play around with it. You can do with it whatever you like. For the compiler-challenged, there are also binary packages available for Autocad R14, Autocad 2000, and Intellicad 2000. Please note that the binary packages require a functional Python 1.5.2 installation on your system to work. If you want to use Pyacad with Python 2.0, then you'll have to compile it yourself for the moment. As far as I understand, no code changes should be required for Python 2.0, except for linking to the new Python.lib. Please tell me if you find this not to be the case.
The source archive contains a VC++5.0 workspace with everything you need to compile for Autocad R14, Autocad 2000 and Intellicad 2000. Theoretically, compiling for R12 or R13 should also work, but is untested. In fact, the modifications required to run it with R11 and earlier should be fairly trivial, even for unix systems. There are seperate "main_XX.c[pp]" files and VC++ projects for the Autocad/Intellicad releases that are currently supported, which makes porting fairly simple.
If you like what you see and would love to see more, then you are welcome to help me finish it. The ADS API has more than hundred functions, many of which would be useful to expose to Python (some should be kept internal). If you want to implement some of them, please tell me, so that I can maintain a list and try to keep other people from doing the same work again. Your results will of course be integrated into the complete package as soon as they're ready, including all the appropriate credentials.
Btw: The documentation of the full ObjectARX API to Autocad would, when printed, fill several thousand pages of paper. If you feel really adventurous, that would be a nice project... ;-)
Pyacad 0.4.1 Copyright © 2000-2001 Georg Mischler. Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies and that both the copyright notice and this permission notice appear in all supporting documentation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.