<?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 Call AutoLISP Function from C# Code in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5521845#M41257</link>
    <description>&lt;P&gt;I'm trying to write a function to simplify the process of calling an AutoLISP function from C#.NET. Right now my code is structured like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static class LanguageExtensions&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; public static List&amp;lt;String&amp;gt; executeLISPFunction(string functionName)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;List&amp;lt;String&amp;gt; funcReturnValues = new List&amp;lt;String&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Call lisp function and set funcReturnValues equal to the values the AutoLISP function returns&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return funcReturnValues;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to know if the approach I'm taking is possible and if so how I would replace the comment with code that does what the comment describes. Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Feb 2015 19:19:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-02-26T19:19:25Z</dc:date>
    <item>
      <title>Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5521845#M41257</link>
      <description>&lt;P&gt;I'm trying to write a function to simplify the process of calling an AutoLISP function from C#.NET. Right now my code is structured like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static class LanguageExtensions&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; public static List&amp;lt;String&amp;gt; executeLISPFunction(string functionName)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;List&amp;lt;String&amp;gt; funcReturnValues = new List&amp;lt;String&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Call lisp function and set funcReturnValues equal to the values the AutoLISP function returns&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return funcReturnValues;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to know if the approach I'm taking is possible and if so how I would replace the comment with code that does what the comment describes. Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 19:19:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5521845#M41257</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-02-26T19:19:25Z</dc:date>
    </item>
    <item>
      <title>Re : Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5521868#M41258</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may have a look at the Autodesk.AutoCAD.ApplicationServices.Application.Invoke() method.&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class="hps"&gt;Note that if the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;LISP&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;function called&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;returns a LISP list&lt;/SPAN&gt;&lt;/SPAN&gt;, it will be converted in .NET into a ResultBuffer.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 19:32:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5521868#M41258</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2015-02-26T19:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5522039#M41259</link>
      <description>&lt;P&gt;To be avoided unless absolutely, full stop, no other option.&amp;nbsp; Otherwise put the effort into converting the LISP&amp;nbsp;into dotNET - you'll save yourself a *lot* of hair pulling.&amp;nbsp; With some judicious writing you can&amp;nbsp;even&amp;nbsp;make the necessary parts of the functions callable from existing LISP.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 21:23:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5522039#M41259</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2015-02-26T21:23:46Z</dc:date>
    </item>
    <item>
      <title>Re : Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5522049#M41260</link>
      <description>&lt;P&gt;It wants me to pass a ResultBuffer in as an argument. Should I create a ResultBuffer with the args I want to pass into the LISP function and pass that in?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 21:28:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5522049#M41260</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-02-26T21:28:20Z</dc:date>
    </item>
    <item>
      <title>Re : Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5522088#M41261</link>
      <description>&lt;P&gt;Yes, and the first item in the ResultBuffer must be the LISP function name (as string).&lt;/P&gt;
&lt;P&gt;if the called function is not prefixed with 'c:', you have to use the &lt;EM&gt;vl-acad-defun&lt;/EM&gt; LISP function to make it is accessible from an external ObjectARX or .NET application.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, I agree with dgorsman, avoid this kind of stuff if you can.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 21:56:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5522088#M41261</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2015-02-26T21:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5523151#M41262</link>
      <description>&lt;P&gt;the problem with avoiding mixing lisp and .net is most environments that customize have a fair amount of lisp that runs stable, and you cannot just port over to .net fast and expect the same stability/behavior.&amp;nbsp; Different issues arise in .net than lisp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to stay within a language too, but the more important thing is knowing how to mix them in a predictable stable manner.&lt;/P&gt;&lt;P&gt;I do a lot of what I call "simple" mixing, and have found one critical issue:&lt;/P&gt;&lt;P&gt;.net modifies the list a lisp function returns.&lt;/P&gt;&lt;P&gt;It turns certain things like lists of three integers into a point in the rbuff codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I do not want to babysit that in every place I do mixing, I send only a single string as the parameter/return val back and forth between .net and lisp.&lt;/P&gt;&lt;P&gt;That string is the serialized resultbuffer/list, which .net always keeps intact.&lt;/P&gt;&lt;P&gt;So you must have serializing/deserializing functions on both ends, but its fast and stable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example case I did this for is the colordialog, which is missing truecolor tab&amp;nbsp;in the lisp version.&lt;/P&gt;&lt;P&gt;I made a .net lispfunction using the .net color dialog, and send back the color chosen.&lt;/P&gt;&lt;P&gt;If rgb, that is three integers which .net screws up, so serializing is better.&lt;/P&gt;&lt;P&gt;You could do simple comma delim for simple lists, but my other lists are not simple so...&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2015 17:23:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5523151#M41262</guid>
      <dc:creator>JamesMaeding</dc:creator>
      <dc:date>2015-02-27T17:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5523189#M41263</link>
      <description>&lt;P&gt;I mix quite a bit, but only in one direction.&amp;nbsp; I port code to dotNET and make it callable from LISP but not in the other direction.&amp;nbsp; With lots of LISP code, I have made sure it is well constructed, black-box style coding so whats in the box doesn't matter.&amp;nbsp; I just swap one box for another.&amp;nbsp; A good example of this is our standards system - I've moved from INI/CFG data files to XML, from LISP to dotNET, and from dynamic accesss to version-controlled cached data, with no problems in stability and minimal work.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2015 18:07:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/5523189#M41263</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2015-02-27T18:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9791535#M41264</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/296193"&gt;@JamesMaeding&lt;/a&gt;&amp;nbsp;I realize this post is several years old; however, it appears that you know how to do what I need to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a lisp routine that gathers Pipe Network object properties and makes use of them.&amp;nbsp; Everything works fine as I use the structure description to glean the size (assumed to be the same as 'InnerDiameter) as an alternative to (VLAX-GET-PROPERTY &amp;lt;structure object&amp;gt; 'InnerDiameter) which does not work.&amp;nbsp; Since the description can be anything (including incorrect) I would like to get the property using C#.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If possible, I need to know how I can tell C# which specific structure my lisp function is examining and have C# get its 'InnerDiameter property and return it to my autolisp function.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 14:00:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9791535#M41264</guid>
      <dc:creator>hencoop</dc:creator>
      <dc:date>2020-10-08T14:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9791598#M41265</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/296193"&gt;@JamesMaeding&lt;/a&gt;&amp;nbsp;I think I've found the help I need here:&amp;nbsp;&lt;A href="https://www.theswamp.org/index.php?topic=35714.0" target="_blank" rel="noopener"&gt;https://www.theswamp.org/index.php?topic=35714.0&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 14:27:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9791598#M41265</guid>
      <dc:creator>hencoop</dc:creator>
      <dc:date>2020-10-08T14:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9791894#M41266</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1152254"&gt;@hencoop&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like you found a good example.&lt;/P&gt;&lt;P&gt;A lisp list in c# and C++ is a resultbuffer. They should have saved themselves the typing and called it a list from the start!&lt;/P&gt;&lt;P&gt;One thing I do is only send one string back and forth between lisp and .net. That string is a "serialized" list, and each side has functions to pack and unpack the string to a list. The reason is a bug related to a list of 3 reals or ints being interpreted as a point. Its been too long for me to remember the specifics but I abandoned using lots of dxf code pairs long ago. You can get away with it until you don't, may never hit you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another trick I ran into is this does not all work great with modeless dialogs. On a few functions, I use .net to set a lisp global variable instead of passing the string. The lisp function knows to read that var after the call and I get around it. Its like a bulletin board approach - definitely not first choice but works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 16:12:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9791894#M41266</guid>
      <dc:creator>JamesMaeding</dc:creator>
      <dc:date>2020-10-08T16:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Call AutoLISP Function from C# Code</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9792581#M41267</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/296193"&gt;@JamesMaeding&lt;/a&gt;&amp;nbsp;&amp;nbsp;Thank you.&amp;nbsp; I thought those words but as I was shutting things down this evening I realized I never said them to you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 21:07:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autolisp-function-from-c-code/m-p/9792581#M41267</guid>
      <dc:creator>hencoop</dc:creator>
      <dc:date>2020-10-08T21:07:11Z</dc:date>
    </item>
  </channel>
</rss>

