I have a C++ dll I have written (native, not .net), and I would like to use its functionality from Visual Lisp. Can anyone point me to an example of how to do this, or at least which bit of documentation to read?
Asked
Active
Viewed 2,588 times
2 Answers
6
I solved this by writing an activex/COM wrapper for my dll, which I think should make it easier to link to in future. Starting a thread on the swamp yielded some answers from nice people about how to call COM from Visual Lisp. For the record, it looks something like this:
//in c++... (header and IDL file also needed)
hresult timestwo(double in,double* out)
{
*out = in*2;
return S_OK;
}
;; in Lisp...
(vl-load-com)
(setq myinstance (vlax-create-object "mycomwrapperdll.mycomwrapperclass"))
(setq num 12.34)
(vlax-invoke-method myinstance 'timestwo num 'newnum)
(vlax-release-object myinstance)
;; newnum now contains 24.68

Sideshow Bob
- 4,566
- 5
- 42
- 79
4
You expose your native C++ code to AutoLisp using the acedDefun() and acedRegFunc() API calls.
Here is a discussion on Autodesk's programming forum asking exactly your question.

Rodney Schuler
- 2,158
- 4
- 23
- 34
-
1That looks like a slightly different question to me - the poster has made an ObjectARX app which is something I am trying to steer clear of. I'd like to call an existing DLL from lisp, ideally without modifying the DLL. Is that possible? – Sideshow Bob Dec 13 '11 at 10:41
-
1I know that AutoLisp has some COM hooks, but I cannot really comment on that approach as I have not personally used it. I always thought that building a thin ObjectARX (or .NET equivalent) connector .dll was the easier approach. (But then again I have been a C++ programmer for decades :) – Rodney Schuler Dec 13 '11 at 14:02