I can't answer the first bit as I don't have 2009 but for the second bit, I doubt it. They are completely different languages. I have had to re-write my routines to take from LISP to VBA.


Registered forum members do not see this ad.
Guys 2009 acad has a action recoredr function - is there some way of recording what a lisp does to transform it into Vba??
Long shot i know - but does anyone know is there some sort of interface between a lisp and vba??
Because id like to transfer a couple of lisps into vba
I can't answer the first bit as I don't have 2009 but for the second bit, I doubt it. They are completely different languages. I have had to re-write my routines to take from LISP to VBA.
"That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson
Dave
At practise just every AutoCAD VBA code can translate into AutoLISP without any alhorithm changes, but you cannot translate every AutoLISP code into VBA. LISP can use all ActiveX methods and properties VBA use, otherwise VBA has't functions and data processing/storage methods use LISP. LISP is LISt Processing Language, VBA hasn't such data type as 'list' and functions to process it. If the program is written on real LISP you can't to use this algorithm for VBA, but can write the VBA-program with similar result.


Russell
That is very wishful thinking
Wouldn't that be nice?
I have code that will allow you to pass Sting Variables and Integers between the two. VBA and LISP
Please see the next post


The examples I created will hopefully get you going.
At the bottom are the 2 needed functions
If you have questions, feel free to ask.
ML
*The original source of this code came from The VLAX Class Module*
Code:Sub Lisp2VBA() 'Uses The GetLispSym Function Dim Variable1 As String Dim Variable2 As String Dim Variable3 As String Dim Variable4 As String 'T1 and T2 are your LISP variables Variable1 = GetLispSym("T1") 'At the command line, set your variable ie (setq T1 "Test1") Variable2 = GetLispSym("T2") 'At the command line, set your variable ie (setq T2 "Test2") 'Return Values Debug.Print Variable1 'Should return Test1 Debug.Print Variable2 'Should return Test2 MsgBox Variable1 'Should return Test1 MsgBox Variable2 'Should return Test2 'Setting and retreiving multiple variables at once. 'B and C are your LISP variables 'At the command line, set your variables ie (setq B 123 C 4.7) Variable3 = GetLispSym("B") Variable4 = GetLispSym("C") 'Return Values Debug.Print Variable3 'Should return 123 Debug.Print Variable4 'Should return 4.7 MsgBox Variable3 'Should return 123 MsgBox Variable4 'Should return 4.7 End Sub Sub VBA2Lisp() 'Uses The PutLispSym Function Dim Num As Integer Dim Txt As String Num = 120 Txt = "String of Text" 'V1 and V2 are your LISP variables PutLispSym "V1", Num 'At the command line, type !V1. The variable (V1) should return 120 PutLispSym "V2", Txt 'At the command line, type !V2. The variable (V2) should return: String of Text End Sub Sub VBA2LispBack2VBA() 'Uses The Put and GetLispSym Functions combined Dim Num As Integer Dim Txt As String Dim Variable1 As Integer Dim Variable2 As String Num = 120 Txt = "String of Text" 'Int and Tx are your LISP variables PutLispSym "Int", Num 'Same as setting your variable (setq Int 120)at the command line PutLispSym "Tx", Txt 'Same as setting your variable (setq Tx "String of Text")at the command line Variable1 = GetLispSym("Int") 'Retreive the variable Int Variable2 = GetLispSym("Tx") 'Retreive the variable Tx 'Return Values Debug.Print Variable1 Debug.Print Variable2 MsgBox Variable1 MsgBox Variable2 End SubCode:Function GetLispSym(symbolName As String) As Variant 'Retrieves a variable from ACAD (LISP) Dim sym As Object Set VL = CreateObject("VL.Application.16") Set sym = VL.ActiveDocument.Functions.Item("read").funcall(symbolName) GetLispSym = VL.ActiveDocument.Functions.Item("eval").funcall(sym) Set VL = Nothing Set sym = Nothing End Function Function PutLispSym(symbolName As String, Value As Variant) 'Sends a variable from VBA to ACAD (LISP) Dim sym As Object Set VL = CreateObject("VL.Application.16") Set sym = VL.ActiveDocument.Functions.Item("read").funcall(symbolName) VL.ActiveDocument.Functions.Item("set").funcall sym, Value Set VL = Nothing Set sym = Nothing End Function




There was some time ago a lisp to C converter it rewrote the code the authors may have written a lisp to VBA the code is very similar. It requires a dictionary of lisp command = VBA command
Try l2c lisp to c on google


Thank you all - good response
So i just supposed i'll have to simply learn VBA -
thanks all i will delv more into the VBA world.
Thank you kindly


Hi Russell
Learning VB(A) is never a bad idea.
I am not really a LISP guy but I have dabbled a bit in the past
I developed the above code more out of curiosity then practicality
While it is not a translator and you will likely not find one, the above code can be used effectively in some real examples
For instance, in the first example, where I have:
Dim Variable1 as String
Variable1 = GetLispSym("T1")
Let's suppose you did some Lisp code and used The getfiled method.
(setq fn (getfiled "Select Block" (getvar "dwgprefix") "dwg");
In VBA, you could use the above to do something like this:
This example would work if well if you had an ACAD menu macro run a Lisp routine that you already created, that is using GetFiled to prompt a user for a block (variable fn) to be inserted, then with the same menu macro, you load and run the VBA macro with the above code in it.Code:Sub BlknamefromLISP () Dim Blkref as AcadBlockReference Dim blkname as String Dim InsPnt As Variant ThisDrawing.ActiveSpace = acModelSpace 'Prompt the user to pick a point InsPnt = ThisDrawing.Utility.GetPoint(, "Select an insertion point") blkname = GetLispSym("fn") Set Blkref = ThisDrawing.ModelSpace.InsertBlock(InsPnt, Blkname, 1, 1, 1, 0) End Sub
Example:
In a case like that, this method would workCode:(load "LispProject")Blocks;^c^c-vbarun;"K:/Path/BlockProj.dvb!Blocks.BlkRef";
If I were using The LISPtoVBA code (above), I would be more inclined to send a few variables from VBA to LISP so that I could use them at the command line in ACAD.
It just all just depends on what you are doing specifically.
Good Luck
ML


Actually, in that example, it would be somethinng like this:
Code:(load "LispProject")Blocks;^c^c-vbarun;"K:/Path/BlockProj.dvb!Blocks.BlknamefromLISP";


Registered forum members do not see this ad.
hey thanks for that - ive been using it and looking into the vba..![]()
thanks for you extensive reply mate - it has gotten me off to a good start with VBA.
Cheers
Bookmarks