<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Connecting vba to lisp in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355038#M72599</link>
    <description>If you want to use data in your VB application that is set with setq in LISP, you can use a not documented object called VL.Application. This only works when Autocad is running and some Lisp program was running (to startup the Lisp subsystem). It is also simple to start Lisp programs from VB (e.g. through sendcommand). So it might be useful to consider to use a VB main which calls Lisp.&lt;BR /&gt;
&lt;BR /&gt;
Below an object that handles the Lisp-connection:&lt;BR /&gt;
&lt;BR /&gt;
Private VL As Object    ' variable for lisp interface object&lt;BR /&gt;
&lt;BR /&gt;
' This function returns the value of  a Lisp symbol.&lt;BR /&gt;
' The Lisp symbol can be set in Lisp like:  (setq x 1234)&lt;BR /&gt;
Public Function GetLispSym(symbolName As String) As Variant&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   ' Get the Lisp symbol 'symbolName'.&lt;BR /&gt;
   GetLispSym = vbEmpty&lt;BR /&gt;
   If VL Is Nothing Then Exit Function&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   GetLispSym = VL.ActiveDocument.Functions.item("eval").funcall(sym)&lt;BR /&gt;
End Function&lt;BR /&gt;
   &lt;BR /&gt;
' This function gets a Lisp list&lt;BR /&gt;
' and put its elements into a&lt;BR /&gt;
' Variant array.&lt;BR /&gt;
' The list can be something like:&lt;BR /&gt;
' (100 1.234 "string")&lt;BR /&gt;
Public Function GetLispList(symbolName As String) As Variant&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   Dim list As Object&lt;BR /&gt;
   Dim items As Long&lt;BR /&gt;
   Dim item As Variant&lt;BR /&gt;
   Dim i As Long&lt;BR /&gt;
   GetLispList = vbEmpty&lt;BR /&gt;
   If VL Is Nothing Then Exit Function&lt;BR /&gt;
   ' Get the Lisp symbol 'symbolName'.&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   Set list = VL.ActiveDocument.Functions.item("eval").funcall(sym)&lt;BR /&gt;
   ' Get the number of elements in this list.&lt;BR /&gt;
   items = VL.ActiveDocument.Functions.item("length").funcall(list)&lt;BR /&gt;
   ReDim VarItems(0 To items - 1) As Variant&lt;BR /&gt;
   ' Get every item from the list.&lt;BR /&gt;
   For i = 1 To items&lt;BR /&gt;
    item = VL.ActiveDocument.Functions.item("nth").funcall(i - 1, list)&lt;BR /&gt;
    VarItems(i - 1) = item&lt;BR /&gt;
   Next&lt;BR /&gt;
   GetLispList = VarItems&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
' This function creates a new Lisp symbol 'symbolName'.&lt;BR /&gt;
' It gets the value specified by 'value'.&lt;BR /&gt;
Public Sub PutLispSym(symbolName As String, value As Variant)&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   If VL Is Nothing Then Exit Sub&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   VL.ActiveDocument.Functions.item("set").funcall sym, value&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This function creates a new Lisp list&lt;BR /&gt;
' and assigns it to the symbol 'symbolName'.&lt;BR /&gt;
' The 'values' parameter has to contain&lt;BR /&gt;
' an array of variants, and this array&lt;BR /&gt;
' is converted to the Lisp list:&lt;BR /&gt;
' Array: "VBA" 100 1.234&lt;BR /&gt;
' List: ("VBA" 100 1.234)&lt;BR /&gt;
Public Sub PutLispList(symbolName As String, values As Variant)&lt;BR /&gt;
   ' Initialize the list using the first value.&lt;BR /&gt;
   Dim list As Object&lt;BR /&gt;
   Dim newList As Object&lt;BR /&gt;
   Dim item As Long&lt;BR /&gt;
   If VL Is Nothing Then Exit Sub&lt;BR /&gt;
   Set list = VL.ActiveDocument.Functions.item("list").funcall(values(0))&lt;BR /&gt;
   ' Append the other items&lt;BR /&gt;
   For item = LBound(values) + 1 To UBound(values)&lt;BR /&gt;
    ' Create a new list for the next item...&lt;BR /&gt;
    Set newList = VL.ActiveDocument.Functions.item("list").funcall(values(item))&lt;BR /&gt;
    ' ...and append it to the existing list.&lt;BR /&gt;
    Set list = VL.ActiveDocument.Functions.item("append").funcall(list, newList)&lt;BR /&gt;
   Next&lt;BR /&gt;
   ' Assign the new list to 'symbolName'&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   Dim res As Object&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   Set res = VL.ActiveDocument.Functions.item("set").funcall(sym, list)&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Class_Initialize()&lt;BR /&gt;
'   Get the VisualLisp Automation interface&lt;BR /&gt;
    Set VL = Nothing&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set VL = CreateObject("VL.Application.1")&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Class_Terminate()&lt;BR /&gt;
    Set VL = Nothing&lt;BR /&gt;
End Sub</description>
    <pubDate>Wed, 17 Jul 2002 04:09:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2002-07-17T04:09:25Z</dc:date>
    <item>
      <title>Connecting vba to lisp</title>
      <link>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355035#M72596</link>
      <description>I have a written a lisp that needs linking to vba. My lisp dumps output&lt;BR /&gt;
information to a csv file.  I don't know much about vba, but there's a guy&lt;BR /&gt;
in our office that can write vba, and he wants to know if he can incorporate&lt;BR /&gt;
his  vba program within my lisp. I reckon thats impossible! Is that right&lt;BR /&gt;
guys? So how do you connect lisp with vba? Do you need to shell out?&lt;BR /&gt;
I remember Tony Tanzillo saying recently in one of the posts it's difficult.&lt;BR /&gt;
However all my information is in the form of strings, which may make it&lt;BR /&gt;
easier&lt;BR /&gt;
T.I.A. Russ&lt;BR /&gt;
&lt;BR /&gt;
(I have put the same post in the customization ng,&lt;BR /&gt;
but I wanted to see what you guys had to say)</description>
      <pubDate>Sat, 13 Jul 2002 16:31:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355035#M72596</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-07-13T16:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting vba to lisp</title>
      <link>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355036#M72597</link>
      <description>Hi Kiwi,&lt;BR /&gt;
I haven't tried to link them yet so unfortunately I'm not the one with the&lt;BR /&gt;
answers.&lt;BR /&gt;
But I've seen lots of posts on the subject.  Lisp can call a vba sub.  Vba&lt;BR /&gt;
could call a lisp with Send Command. But there's timing problems using that&lt;BR /&gt;
approach.  As a side note, if you're writing with any of the vla functions&lt;BR /&gt;
you're already writing vba. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I think it depends on exactly how you need&lt;BR /&gt;
to link them.  If your lisp is just outputting to a text file you could have&lt;BR /&gt;
vba read the file and do whatever it needed to do with the info.  If vba has&lt;BR /&gt;
to do some work and then give results to lisp then again any stored kind of&lt;BR /&gt;
information, eg external: text file, database, binary file. or internal:&lt;BR /&gt;
variable, dictionary, xrecord, xdata, attributes, text entities, etc would&lt;BR /&gt;
be readable and writable by either language.  But getting them (vb and&lt;BR /&gt;
lisp)to 'run time' mesh together and stay in sync, that seems to be the&lt;BR /&gt;
difficulty from what people have said.  Vba can start the lisp but may not&lt;BR /&gt;
be able to tell when it's done running or when information has been set and&lt;BR /&gt;
is ready to read, if it tries to retreive some value back from the lisp. if&lt;BR /&gt;
that makes any sense.  You may need to be a little more specific what you&lt;BR /&gt;
want to do. the pros here will definitely offer the specific solution or&lt;BR /&gt;
point the way.  or you and your co-worker could do a mind-meld and then&lt;BR /&gt;
you'd both know both languages....frightening...&lt;BR /&gt;
:-)  you can do it! Have fun. Mark&lt;BR /&gt;
&lt;BR /&gt;
Kiwi Russ &lt;RUSSELL&gt; wrote in message&lt;BR /&gt;
news:DAEFD0042A08F66C2FC3A75F67BF76C0@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; I have a written a lisp that needs linking to vba. My lisp dumps output&lt;BR /&gt;
&amp;gt; information to a csv file.&lt;BR /&gt;
you could also write it to a dictionary which vba could then read?&lt;BR /&gt;
&lt;BR /&gt;
 I don't know much about vba, but there's a guy&lt;BR /&gt;
&amp;gt; in our office that can write vba, and he wants to know if he can&lt;BR /&gt;
incorporate&lt;BR /&gt;
&amp;gt; his  vba program within my lisp. I reckon thats impossible! Is that right&lt;BR /&gt;
&amp;gt; guys? So how do you connect lisp with vba? Do you need to shell out?&lt;BR /&gt;
&amp;gt; I remember Tony Tanzillo saying recently in one of the posts it's&lt;BR /&gt;
difficult.&lt;BR /&gt;
&amp;gt; However all my information is in the form of strings, which may make it&lt;BR /&gt;
&amp;gt; easier&lt;BR /&gt;
&amp;gt; T.I.A. Russ&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; (I have put the same post in the customization ng,&lt;BR /&gt;
&amp;gt; but I wanted to see what you guys had to say)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/RUSSELL&gt;</description>
      <pubDate>Sat, 13 Jul 2002 18:28:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355036#M72597</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-07-13T18:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting vba to lisp</title>
      <link>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355037#M72598</link>
      <description>Hi Russ,&lt;BR /&gt;
There are a couple of articles on our site covering this subject.  Read&lt;BR /&gt;
"Data Exchange with VBA and LISP" and "Writing hybrid apps".  And as always,&lt;BR /&gt;
post any specific questions here and I'm sure that someone will be able to&lt;BR /&gt;
help.&lt;BR /&gt;
--&lt;BR /&gt;
Bobby C. Jones&lt;BR /&gt;
www.AcadX.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Kiwi Russ" &lt;RUSSELL&gt; wrote in message&lt;BR /&gt;
news:DAEFD0042A08F66C2FC3A75F67BF76C0@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; I have a written a lisp that needs linking to vba. My lisp dumps output&lt;BR /&gt;
&amp;gt; information to a csv file.  I don't know much about vba, but there's a guy&lt;BR /&gt;
&amp;gt; in our office that can write vba, and he wants to know if he can&lt;BR /&gt;
incorporate&lt;BR /&gt;
&amp;gt; his  vba program within my lisp. I reckon thats impossible! Is that right&lt;BR /&gt;
&amp;gt; guys? So how do you connect lisp with vba? Do you need to shell out?&lt;BR /&gt;
&amp;gt; I remember Tony Tanzillo saying recently in one of the posts it's&lt;BR /&gt;
difficult.&lt;BR /&gt;
&amp;gt; However all my information is in the form of strings, which may make it&lt;BR /&gt;
&amp;gt; easier&lt;BR /&gt;
&amp;gt; T.I.A. Russ&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; (I have put the same post in the customization ng,&lt;BR /&gt;
&amp;gt; but I wanted to see what you guys had to say)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/RUSSELL&gt;</description>
      <pubDate>Mon, 15 Jul 2002 07:20:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355037#M72598</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-07-15T07:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting vba to lisp</title>
      <link>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355038#M72599</link>
      <description>If you want to use data in your VB application that is set with setq in LISP, you can use a not documented object called VL.Application. This only works when Autocad is running and some Lisp program was running (to startup the Lisp subsystem). It is also simple to start Lisp programs from VB (e.g. through sendcommand). So it might be useful to consider to use a VB main which calls Lisp.&lt;BR /&gt;
&lt;BR /&gt;
Below an object that handles the Lisp-connection:&lt;BR /&gt;
&lt;BR /&gt;
Private VL As Object    ' variable for lisp interface object&lt;BR /&gt;
&lt;BR /&gt;
' This function returns the value of  a Lisp symbol.&lt;BR /&gt;
' The Lisp symbol can be set in Lisp like:  (setq x 1234)&lt;BR /&gt;
Public Function GetLispSym(symbolName As String) As Variant&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   ' Get the Lisp symbol 'symbolName'.&lt;BR /&gt;
   GetLispSym = vbEmpty&lt;BR /&gt;
   If VL Is Nothing Then Exit Function&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   GetLispSym = VL.ActiveDocument.Functions.item("eval").funcall(sym)&lt;BR /&gt;
End Function&lt;BR /&gt;
   &lt;BR /&gt;
' This function gets a Lisp list&lt;BR /&gt;
' and put its elements into a&lt;BR /&gt;
' Variant array.&lt;BR /&gt;
' The list can be something like:&lt;BR /&gt;
' (100 1.234 "string")&lt;BR /&gt;
Public Function GetLispList(symbolName As String) As Variant&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   Dim list As Object&lt;BR /&gt;
   Dim items As Long&lt;BR /&gt;
   Dim item As Variant&lt;BR /&gt;
   Dim i As Long&lt;BR /&gt;
   GetLispList = vbEmpty&lt;BR /&gt;
   If VL Is Nothing Then Exit Function&lt;BR /&gt;
   ' Get the Lisp symbol 'symbolName'.&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   Set list = VL.ActiveDocument.Functions.item("eval").funcall(sym)&lt;BR /&gt;
   ' Get the number of elements in this list.&lt;BR /&gt;
   items = VL.ActiveDocument.Functions.item("length").funcall(list)&lt;BR /&gt;
   ReDim VarItems(0 To items - 1) As Variant&lt;BR /&gt;
   ' Get every item from the list.&lt;BR /&gt;
   For i = 1 To items&lt;BR /&gt;
    item = VL.ActiveDocument.Functions.item("nth").funcall(i - 1, list)&lt;BR /&gt;
    VarItems(i - 1) = item&lt;BR /&gt;
   Next&lt;BR /&gt;
   GetLispList = VarItems&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
' This function creates a new Lisp symbol 'symbolName'.&lt;BR /&gt;
' It gets the value specified by 'value'.&lt;BR /&gt;
Public Sub PutLispSym(symbolName As String, value As Variant)&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   If VL Is Nothing Then Exit Sub&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   VL.ActiveDocument.Functions.item("set").funcall sym, value&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This function creates a new Lisp list&lt;BR /&gt;
' and assigns it to the symbol 'symbolName'.&lt;BR /&gt;
' The 'values' parameter has to contain&lt;BR /&gt;
' an array of variants, and this array&lt;BR /&gt;
' is converted to the Lisp list:&lt;BR /&gt;
' Array: "VBA" 100 1.234&lt;BR /&gt;
' List: ("VBA" 100 1.234)&lt;BR /&gt;
Public Sub PutLispList(symbolName As String, values As Variant)&lt;BR /&gt;
   ' Initialize the list using the first value.&lt;BR /&gt;
   Dim list As Object&lt;BR /&gt;
   Dim newList As Object&lt;BR /&gt;
   Dim item As Long&lt;BR /&gt;
   If VL Is Nothing Then Exit Sub&lt;BR /&gt;
   Set list = VL.ActiveDocument.Functions.item("list").funcall(values(0))&lt;BR /&gt;
   ' Append the other items&lt;BR /&gt;
   For item = LBound(values) + 1 To UBound(values)&lt;BR /&gt;
    ' Create a new list for the next item...&lt;BR /&gt;
    Set newList = VL.ActiveDocument.Functions.item("list").funcall(values(item))&lt;BR /&gt;
    ' ...and append it to the existing list.&lt;BR /&gt;
    Set list = VL.ActiveDocument.Functions.item("append").funcall(list, newList)&lt;BR /&gt;
   Next&lt;BR /&gt;
   ' Assign the new list to 'symbolName'&lt;BR /&gt;
   Dim sym As Object&lt;BR /&gt;
   Dim res As Object&lt;BR /&gt;
   Set sym = VL.ActiveDocument.Functions.item("read").funcall(symbolName)&lt;BR /&gt;
   Set res = VL.ActiveDocument.Functions.item("set").funcall(sym, list)&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Class_Initialize()&lt;BR /&gt;
'   Get the VisualLisp Automation interface&lt;BR /&gt;
    Set VL = Nothing&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Set VL = CreateObject("VL.Application.1")&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Class_Terminate()&lt;BR /&gt;
    Set VL = Nothing&lt;BR /&gt;
End Sub</description>
      <pubDate>Wed, 17 Jul 2002 04:09:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355038#M72599</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-07-17T04:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting vba to lisp</title>
      <link>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355039#M72600</link>
      <description>Many thanks to the replies. Now I am fairly confident I that I can complete&lt;BR /&gt;
the project.&lt;BR /&gt;
I may have a few specific questions later regarding this vba thingy.&lt;BR /&gt;
cheers Russ</description>
      <pubDate>Fri, 19 Jul 2002 02:18:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/connecting-vba-to-lisp/m-p/355039#M72600</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-07-19T02:18:42Z</dc:date>
    </item>
  </channel>
</rss>

