OO programming in Autocad?
January 2, 2006 6:31 AM   Subscribe

I have developed an application in AutoLISP which I would like to re-write in an OO language. AutoCAD seems to natively support VB but I don't think I want to go there. I am starting to learn C# and Python, and like both. How easy is it to link Autocad and C# or Python (or Ruby, etc.)? I am aware of PyCad but not sure I understand how to get it to work, plus it requires Autocad 2000 which is like requiring windows 95. In short, I am quite the newbie at this and would appreciate a simple but thorough explanation of how to use a modern programming language in Autocad.
posted by signal to Computers & Internet (7 answers total)
 
You may want to look into ObjectARX (AutoCAD Runtime eXtension). It is a C++ programming environment that runs in all recent versions of AutoCAD (from 2002 up).
posted by nkyad at 6:45 AM on January 2, 2006


can't help directly, but lisps often have oo extensions available (which tend to work quite well, since lisp tends to be easy to extend). so it's possible you could stay using autolisp.

hmmm. this looks ancient and unsupported. so perhaps not.

it seems that they have support for interfacing to c, called ads. so you could use c++ directly (but i advise against it). languages like python, ruby, typically have packages that let you auto-generate interfaces from c headers (eg swig). that might be an alternative route, but doesn't sound that easy.

if they support vb then, given .net, does that mean they support c# too? ie is it vb.net they support? if so, then c# may "just work".
posted by andrew cooke at 6:45 AM on January 2, 2006


Isn't LISP an OO language?
posted by kenko at 9:05 AM on January 2, 2006


not the autolisp implementation, no. common lisp (the "standard") is, but there are a lot of very similar languages that differ from that standard and still call themselves lisp.
posted by andrew cooke at 10:45 AM on January 2, 2006


Response by poster: nkyad: thanks, I'll look into it, though I don't know if I want to get into c++.

a.c.: I think that you're right about the .net angle, as shown here. Any clues as to how to follow this route to be able to use Python instead? Thanks!

piƱera? pffft. you want to add "momio" to the "gringo" moniker?
posted by signal at 5:47 PM on January 2, 2006


only joking (although i seem to be sharing an office with the pharos).

i have never used c# or vb or .net, so can't really help. but i assume that they all compile to the same thing. so if you follow the instructions for deploying/linking to vb, but use c# tools instead, then it "should" work.
posted by andrew cooke at 5:03 AM on January 3, 2006


Best answer: I'm currently developing an AutoCAD 2006 plugin in C# with the .NET framework.

AutoCAD support for .NET is a relatively new thing, so learning material is scarce: one forum on the Autodesk site and an SDK with API docs, code samples, and some short tutorials. I've found no third-party instructional sites or communities, nor books of any kind.

(As you probably already know from your AutoLISP experience, if you're an ADN member, you also have access to Autodesk's online knowledge base, and can contact Autodesk support with questions. They don't respond quickly, but their responses are generally very good.)

Basically what Autodesk has done to support .NET integration is wrap up all the existing ObjectARX code with .NET classes. There's generally (but not always) a one-to-one mapping between a ObjectARX class or function and a .NET equivalent. Expect to spend lots of time looking for .NET documentation for a particular class, finding it incomplete or nonexistent, and then switching over to the Object ARX counterpart, reading the sample C++ code, and then figuing out how to make it work in .NET.

For all the frustrating hours I've spent working around these issues, there are some really nice benefits to working in .NET. Your AutoCAD plugin can exploit the full range of .NET features -- the two most useful for me have been connecting to remote web services and building GUI forms, both of which are ridiculously easy with .NET.

Anyway, if you've already got Visual Studio on your machine, I would recommend checking out the SDK. You should pretty quickly be able to write a "Hello, World!" application and get a feel for the environment.

Good luck!
posted by medpt at 11:17 AM on January 3, 2006


« Older Iranian Blogs in English   |   Apt Neighbor Blares TV-- I need sleep! Newer »
This thread is closed to new comments.