<?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: load and run .lsp from C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/5087300#M69269</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this topic is quite old, but while using the you provided I am getting this error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected class delegate enum interface or struct (at void)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified the code to suit my needs please help me resolve it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code&lt;/P&gt;&lt;P&gt;using Microsoft.Win32;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using acApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;/P&gt;&lt;P&gt;[CommandMethod("TLOD", CommandFlags.Modal)]&lt;/P&gt;&lt;P&gt;public void TLOD()&lt;BR /&gt;{&lt;BR /&gt;AcadDocument curAcadDoc = (AcadDocument)AcApp.DocumentManager.MdiActiveDocument.AcadDocument;&lt;BR /&gt;curAcadDoc.SendCommand("(vl-load-com) "/*space after closing paren!!!*/);&lt;BR /&gt;string lispPath = (string)Registry.LocalMachine.GetValue(@"SOFTWARE\XXXX\YYYY", "InstallDir", null);&lt;BR /&gt;string loadStr = String.Format("(vl-load-all \"{0}\") "/*space after closing paren!!!*/, lispPath);&lt;BR /&gt;curAcadDoc.SendCommand(loadStr);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jun 2014 09:19:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-06-11T09:19:40Z</dc:date>
    <item>
      <title>load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547034#M69265</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
 How can i load .lsp or .vlx from preferable path in C# and run the lisp code at the command prompt. can anyone help me please..&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance

Edited by: divyasree on Aug 27, 2009 3:57 PM</description>
      <pubDate>Thu, 27 Aug 2009 10:21:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547034#M69265</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-27T10:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547035#M69266</link>
      <description>Something like this would work, it uses AutoCAD.Interop:&lt;BR /&gt;
{code}&lt;BR /&gt;
[CommandMethod("TLOD", CommandFlags.Modal)]&lt;BR /&gt;
public void TLOD()&lt;BR /&gt;
{&lt;BR /&gt;
    /*&lt;BR /&gt;
    ;;&lt;BR /&gt;
    ;; contents of "C:/_TLOAD.lsp"&lt;BR /&gt;
    ;;&lt;BR /&gt;
    (defun c:LISPCOM1 ()&lt;BR /&gt;
      (prompt "\nLoaded: C:/_TLOAD.lsp")&lt;BR /&gt;
      (prompt "\nLISPCOM1 Executed!")&lt;BR /&gt;
      (prompt "\nNice")&lt;BR /&gt;
      (princ)&lt;BR /&gt;
    )&lt;BR /&gt;
    */&lt;BR /&gt;
&lt;BR /&gt;
    AcadDocument curAcadDoc = (AcadDocument)AcApp.DocumentManager.MdiActiveDocument.AcadDocument;&lt;BR /&gt;
    string lispPath = "C:/_TLOAD.lsp";&lt;BR /&gt;
    string loadStr = String.Format("(load \"{0}\") "/*space after closing paren!!!*/, lispPath);&lt;BR /&gt;
    curAcadDoc.SendCommand(loadStr);&lt;BR /&gt;
    curAcadDoc.SendCommand("LISPCOM1 "/*space after command name!!!*/);&lt;BR /&gt;
}&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
It won't load it application wide. You would have to run 'TLOD' again for each document that you open.&lt;BR /&gt;
And you can use 'HostApplicationServices.FindFile()' to find a file that might be in AutoCAD's path, if needed.</description>
      <pubDate>Thu, 27 Aug 2009 19:06:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547035#M69266</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2009-08-27T19:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547036#M69267</link>
      <description>Thanks a lot. this code helped me.</description>
      <pubDate>Fri, 28 Aug 2009 10:33:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547036#M69267</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-28T10:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547037#M69268</link>
      <description>No problem! I thought I woudl follow it up with, if you do want a lisp file to be loaded in all dwgs and subsequent opened dwgs:&lt;BR /&gt;
{code}&lt;BR /&gt;
AcadDocument curAcadDoc = (AcadDocument)AcApp.DocumentManager.MdiActiveDocument.AcadDocument;&lt;BR /&gt;
curAcadDoc.SendCommand("(vl-load-com) "/*space after closing paren!!!*/);&lt;BR /&gt;
string lispPath = "C:/_TLOAD.lsp";&lt;BR /&gt;
string loadStr = String.Format("(vl-load-all \"{0}\") "/*space after closing paren!!!*/, lispPath);&lt;BR /&gt;
curAcadDoc.SendCommand(loadStr);&lt;BR /&gt;
{code}</description>
      <pubDate>Mon, 31 Aug 2009 00:17:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/2547037#M69268</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2009-08-31T00:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/5087300#M69269</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this topic is quite old, but while using the you provided I am getting this error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected class delegate enum interface or struct (at void)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified the code to suit my needs please help me resolve it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code&lt;/P&gt;&lt;P&gt;using Microsoft.Win32;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using acApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;/P&gt;&lt;P&gt;[CommandMethod("TLOD", CommandFlags.Modal)]&lt;/P&gt;&lt;P&gt;public void TLOD()&lt;BR /&gt;{&lt;BR /&gt;AcadDocument curAcadDoc = (AcadDocument)AcApp.DocumentManager.MdiActiveDocument.AcadDocument;&lt;BR /&gt;curAcadDoc.SendCommand("(vl-load-com) "/*space after closing paren!!!*/);&lt;BR /&gt;string lispPath = (string)Registry.LocalMachine.GetValue(@"SOFTWARE\XXXX\YYYY", "InstallDir", null);&lt;BR /&gt;string loadStr = String.Format("(vl-load-all \"{0}\") "/*space after closing paren!!!*/, lispPath);&lt;BR /&gt;curAcadDoc.SendCommand(loadStr);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2014 09:19:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/5087300#M69269</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-06-11T09:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/5087318#M69270</link>
      <description>&lt;P&gt;I believe I have to declare the namespace and also public class but I do not know how. Any example Please..&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2014 09:28:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/5087318#M69270</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-06-11T09:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: load and run .lsp from C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/6966886#M69271</link>
      <description>&lt;PRE&gt;AcadDocument curAcadDoc = (AcadDocument)Autodesk.AutoCAD.ApplicationServices.Application .DocumentManager.MdiActiveDocument.GetAcadDocument();
            curAcadDoc.SendCommand("(vl-load-com) "/*space after closing paren!!!*/);
            string lispPath = "C:LU.lsp";
            string loadStr = String.Format("(vl-load-all \"{0}\") "/*space after closing paren!!!*/, lispPath);
            curAcadDoc.SendCommand(loadStr)&lt;/PRE&gt;&lt;P&gt;try with this&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 08:05:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/load-and-run-lsp-from-c/m-p/6966886#M69271</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-23T08:05:51Z</dc:date>
    </item>
  </channel>
</rss>

