From: Martti Halminen
Subject: Using ActiveX from Common Lisp
Date: 
Message-ID: <pan.2004.04.16.01.19.53.731202@kolumbus.fi>
Hello,

I've recently been looking at accessing AutoCAD from Common Lisp using
ActiveX, with limited success: as I have no experience using ActiveX from
any other language, either, I'm making not that much sense from Franz or
Harlequin documentation.

Does anybody happen to have any example code available to get started
either
with Allegro CL or Lispworks? (Beyond the few generic examples in Franz
documentation)
- Has anybody actually even tried this with AutoCAD and CL? Is it
practicable?

(I get a few properties looked up, but anything more involved and the
system
complains about unknown methods.)

-- 

From: Andrew Wolven
Subject: Re: Using ActiveX from Common Lisp
Date: 
Message-ID: <1OmdnbWmRtuS0uLdRVn-tA@comcast.com>
I have quite a bit of code for doing this with Franz.  I am planning on
releasing it open-source at some point, but since I'm not getting paid for
it, and since I am a full time student the project is low on my priority
list.  I would certainly like to help you though.

I have had to write portions of the interface in C, because ACL's OLE system
does not handle COM calls that return multiple values.  That was my major
stumbling block in the past, since at the time I started I didn't know C.
ACL's OLE interface also did not have the feature of being able to get a
handle for a currently open application, it could only spawn a new instance
of the application.  I fixed that too.

Currently my interface consists of two layers, the lower layer is a set of
wrappers that make COM interface objects CLOS objects, and does other things
like loading safearrays from regular lisp arrays.  The upper layer is a set
of writer methods for outputing Genworks GDL geometric objects to Autocad.
Check out www.genworks.com.  GDL used in this manner is essentially a
knowledge-based engineering system.  My current stumbling block is with
bezier curves.  Autocad's spline object when used with COM is created in the
same way you would draw it in autocad, showing the 'scripting' nature of
Autocad's com interface.  I'm trying to figure out how to manipulate
autocad's spline object and turn it into the correct nurbs or bezier.  Nurbs
and bezier curves in lisp (or any other programming language) use a
different data structure than the one accessible in com.  I'm trying to
figure out the mapping, it doesn't have knot vectors, so I'm confused.

Tell me what you wan't to do and I'll post some code.  Meanwhile, as you
experiment with that, I'll try to get a snapshot of my system with some
documentation, but final exams are coming up so it may have to wait till
middle of May.

-Andrew W.

P.S. you may also want to know that autocad runs as an out of process server
in relationship to lisp.  To get it to run as in-process is currently beyond
my abilities as a programmer.  (In process is like VBA, allowing modal
dialogs)  (Out of process means you will get an error in lisp if you try to
tell autocad to do something while it is busy in the middle of a user
command)  In-process is what you really want to write an 'autocad' app.  Out
of process means you are writing a lisp application that happens to drive a
seperate autocad.


"Martti Halminen" <···············@kolumbus.fi> wrote in message
···································@kolumbus.fi...
>
> Hello,
>
> I've recently been looking at accessing AutoCAD from Common Lisp using
> ActiveX, with limited success: as I have no experience using ActiveX from
> any other language, either, I'm making not that much sense from Franz or
> Harlequin documentation.
>
> Does anybody happen to have any example code available to get started
> either
> with Allegro CL or Lispworks? (Beyond the few generic examples in Franz
> documentation)
> - Has anybody actually even tried this with AutoCAD and CL? Is it
> practicable?
>
> (I get a few properties looked up, but anything more involved and the
> system
> complains about unknown methods.)
>
> --
>
>
>
From: Rahul Jain
Subject: Re: Using ActiveX from Common Lisp
Date: 
Message-ID: <87isfy10vf.fsf@nyct.net>
"Andrew Wolven" <·······@nospam.net> writes:

> I have quite a bit of code for doing this with Franz.  I am planning on
> releasing it open-source at some point, but since I'm not getting paid for
> it, and since I am a full time student the project is low on my priority
> list.  I would certainly like to help you though.

Isn't that MORE of a reason for open-sourcing it earlier instead of
later? Let someone else with the need to use it commercially spend the
time on cleaning it up and making it maintainable. They'll be the ones
with the vested interest in the quality of the project at that point.

In any case, carry on. :)

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
From: Andrew Wolven
Subject: Re: Using ActiveX from Common Lisp
Date: 
Message-ID: <7vqdnaNjcsFJH-LdRVn-gw@comcast.com>
Try this, it works for R14 and ACL5.0.1:

(require :ole)

(ole:start-ole)

(setq *autocad* (ole:ask-for-autotool
    "AutoCAD.Application"
    ole:CLSCTX_LOCAL_SERVER))

(setf (ole:auto-getf *autocad* :Visible) t)

(setq *doc*
  (make-instance 'ole:remote-autotool
    :dispatch (ole:auto-getf *autocad* :ActiveDocument)))

(setq *mspace*
  (make-instance 'ole:remote-autotool
    :dispatch (ole:auto-getf *doc* :ModelSpace)))

(setq *center* (ole:make-lisp-safearray 3 :element-type :double))

(require :ole-dev)

(dotimes (n 3) (setf (ole:safearray-aref *center* n) 0.0d0))

(setq *radius* 1)

(setq *circle*
  (make-instance 'ole:remote-autotool
    :dispatch (ole:auto-method *mspace* :AddCircle *center* *radius*)))

Get yourself a copy of OLEVIEW for windows so you can see what other methods
and properties there are for autocad.

"Martti Halminen" <···············@kolumbus.fi> wrote in message
···································@kolumbus.fi...
>
> Hello,
>
> I've recently been looking at accessing AutoCAD from Common Lisp using
> ActiveX, with limited success: as I have no experience using ActiveX from
> any other language, either, I'm making not that much sense from Franz or
> Harlequin documentation.
>
> Does anybody happen to have any example code available to get started
> either
> with Allegro CL or Lispworks? (Beyond the few generic examples in Franz
> documentation)
> - Has anybody actually even tried this with AutoCAD and CL? Is it
> practicable?
>
> (I get a few properties looked up, but anything more involved and the
> system
> complains about unknown methods.)
>
> --
>
>
>
From: Martti Halminen
Subject: Re: Using ActiveX from Common Lisp
Date: 
Message-ID: <pan.2004.04.18.12.31.54.162462@kolumbus.fi>
On Fri, 16 Apr 2004 01:55:10 -0500, Andrew Wolven wrote:

> Try this, it works for R14 and ACL5.0.1:
> 
>>
<snip>

Thank you, this cleared up some misconceptions I had with ACL
documentation.

--