[freearchitecture] Re: [PythonCAD] Looking for DXF help

Terry Hancock hancock at anansispaceworks.com
Fri Feb 13 21:16:29 GMT 2004


On Wednesday 11 February 2004 10:26 pm, Steve Hall wrote:
> > > Has anyone here ever written extensions for A___CAD using Python?
> > > I've heard some stand-alone/static binaries could be compiled for
> > > Win32 from Python, but is this crazy talk? Of course, ALisp can run
> > > and return from binaries, but is this reasonable?
> > like:
> > http://sourceforge.net/projects/pyacad/
> 
> This appears to require the Python environment. Not knowing Python
> (yet), I'm looking for a simple binary distributable that I can run
> from AutoCAD. It won't work if I have to convince my company to
> install Python on 800 machines. ;)
> 
> I guess I was looking for stand alone executables, something that
> might be created with:
> 
>   http://starship.python.net/crew/theller/py2exe/
> 
> Throw in the ability to write GUI dialogs for AutoCAD *with Python*
> and I begin to see a way to write tools (like our thread-starting
> .DXF) that can be Free for the imprisoned yet still useful to a Free
> project like PythonCAD.

I suppose you want someone familiar with Python to tell you
you're not wasting your time? ;-)

Sounds like it should work -- a cursory glance at the CVS repository for
PyACAD shows that it provides a Python Extension module written in C
(I presume this dynamically links against something in AutoCAD to
create the interface?), then there's a PyACAD module for Python.

The .EXE will have to contain all of that -- the compiled extension module
and the the PyACAD module, plus your own source code. This will create
a (rather bloated) .EXE file that you should be able to use.  Presumeably the
requirements for PyACAD are standard in the AutoCAD distribution, so you
don't have to install them (?), and then it's just a question of bundling your
code.

The Python .EXE files are just python bytecode bundled with the interpreter --
they are still interpreted Python, just like any other Python code.  My understanding
is that they are for situations just such as yours.  I've never used them,
though (there's no Linux/Unix equivalent to Py2EXE).

It would clearly be more efficient and maintainable to get your company
to install Python on its machines, and that's what you want in the long run
(that way you're distributing readable 10 KB Python files and not
opaque 2 MB .EXEs).

As for sharing the code with PythonCAD etc, that would obviously depend
on how close the APIs are. *If* a body of Free Python code for AutoCAD
existed, I'm sure there'd be motivation to write such an API for PythonCAD,
to allow them to be used.  I presume these APIs are published, since PyACAD
is on SourceForge.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com


More information about the freearchitecture mailing list