TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mailmaverick on August 29, 2016, 11:55:57 AM
-
How can I load and use C++ DLL by LISP ?
My C++ code is as under :-
int _stdcall useArray(double* dIn1, double* dIn2, double* dOut)
{
;; My code here
}
Source.def has been defined as :
LIBRARY "useArray"
EXPORTS
MyFunction = useArray
This function takes input values dIn1 and dIn2 as arrays and gives output in dOut as an array again.
-
Wait, do you want to load a .DLL file from AutoLISP or load a .LSP from a .DLL?
-
I have a .DLL file created in C++ which has a function named useArray.
I want to use this DLL in AutoLISP.
-
Well if the .DLL is loaded, simply call it like you would any other command.
(setq var
(useArray var1 var2
))
If it is not loaded
(command "_NETLOAD" "useArray.dll")
-
Ah, well that depends if the DLL actually defines a LISP function. If it doesn't, then if it implements COM methods/properties those can be accessed through (vlax-invoke-method ...) and (vlax-get/set-property ...). If neither of those then it cannot be used through LISP.
-
(command "_NETLOAD" "useArray.dll") returns NIL, it does not load.
DLL does not define a LISP function but is a pure C++ DLL.
I think dgorsman's vlax-invoke-method can be used.
But how.
-
In order to netload to work, the DLL needs to be in a folder read by AutoCAD.
-
(command "_NETLOAD" "useArray.dll") returns NIL, it does not load.
DLL does not define a LISP function but is a pure C++ DLL.
I think dgorsman's vlax-invoke-method can be used.
But how.
Those require the DLL to have a COM interface. If its "pure C++" with no COM interface then you still cannot call directly using LISP. If you cannot add LISP functions to the DLL you would need to roll-your-own DLL wrapper to provide the appropriate LISP functions.
-
(command "_NETLOAD" "useArray.dll") returns NIL, it does not load.
DLL does not define a LISP function but is a pure C++ DLL.
I think dgorsman's vlax-invoke-method can be used.
But how.
dgorsman is correct, there is no way to load this dll unless it exposes a COM interface or it is created as an ObjectARX application that exposes a Lisp function interface. The NETLOAD command is used to load .Net assembly dll's, you can't load a native (C++) dll with NETLOAD.
If this was written by youself or you know the person perhaps you can ask them to write it in .Net, that is the easiest way forward IMO.
<added> actually, you would need to expose the .Net dll with a Lisp interface as well, to hook different runtime tecnnologies you need to provide some way for them to talk to each other and these interfaces are what make that possible.
-
Thanks for your comments.
I want to use LISPLAB as given at https://common-lisp.net/project/lisplab/ in Autolisp / Visual LISP.
Can you help me on this.
-
How can I load and use C++ DLL by LISP ?
Just look here https://bitbucket.org/mmamkin/mtmdloaddll
-
that looks good ur_naz!
Will it handle the LISPLAB lib if it doesn't have a COM interface? I couldn't easily tell by looking at the code which by the way is pretty cool and heavy duty, I will be studying that for a while :)
-
How can I load and use C++ DLL by LISP ?
My C++ code is as under :-
int _stdcall useArray(double* dIn1, double* dIn2, double* dOut)
{
;; My code here
}
Source.def has been defined as :
LIBRARY "useArray"
EXPORTS
MyFunction = useArray
This function takes input values dIn1 and dIn2 as arrays and gives output in dOut as an array again.
Lisp can load dlls. A reserved function load-dll is required
This function autodesk is not exposed. The reserved function needs to be converted before it can be used. Look here http://bbs.mjtd.com/thread-185974-1-1.html?_dsign=674e21e0
-
Lisp can load dlls.
A reserved function load-dll is required
This function autodesk is not exposed.
The reserved function needs
to be converted before it can be used.
Look here
http://bbs.mjtd.com/thread-185974-1-1.html?_dsign=674e21e0
I am studying lsp to directly call windows api.
After success, lsp will be as powerful
as other languages
and do whatever you want
This Is very interesting ...
-
Lisp can load dlls.
A reserved function load-dll is required
This function autodesk is not exposed.
The reserved function needs
to be converted before it can be used.
Look here
http://bbs.mjtd.com/thread-185974-1-1.html?_dsign=674e21e0
I am studying lsp to directly call windows api.
After success, lsp will be as powerful
as other languages
and do whatever you want
This Is very interesting ...
xdrx-load-dll
xdrx-unload-dll