<?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: Is Lisp &amp;quot;command&amp;quot; function not available when called from VB Dot N in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455816#M55662</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;CommCorp wrote: &lt;BR /&gt;
&lt;P&gt;[...]One last question, can both of the command methods be in the same class?[...]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. &lt;/P&gt;</description>
    <pubDate>Mon, 14 May 2012 12:04:58 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2012-05-14T12:04:58Z</dc:date>
    <item>
      <title>Is Lisp "command" function not available when called from VB Dot Net?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3451896#M55654</link>
      <description>&lt;P&gt;I'm trying to run a Lisp program by calling it from VB Dot Net.&lt;/P&gt;&lt;P&gt;Just for testing, my Lisp code is as follows...&lt;/P&gt;&lt;PRE&gt;(defun c:DoIt(textb)
	(setq pntA (getpoint "\nPick A")
		  pntB (getpoint pntA "\nPick B")
		  )
(setq curdoc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace curdoc))
(vla-addline mspace (vlax-3d-point pntA) (vlax-3d-point pntB))

; Vlisp works
(vla-addText mspace (car textb) (vlax-3d-point (list 0 0 0)) 3.0)

; command line does not work, returns "invalid AutoCAD command:"
(command "text" "c" (list 0 0 0) 3.0 0.0 textb)
	)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;And my VB Dot Net code is...&lt;/P&gt;&lt;PRE&gt;ublic Class MyPlugin
    &amp;lt;CommandMethod("runlisp", CommandFlags.Session)&amp;gt; _
    Public Sub runlisp()
        Dim commandargs As New ResultBuffer()

        commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.Text, "c:doit"))
        commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.Text, "ceil"))

        'commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.ListBegin, -1))
        'commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.Text, "ceil"))
        'commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.ListEnd, -1))

        Dim m_ResultBuf As IntPtr = IntPtr.Zero
        Dim m_Return As Integer = acedInvoke(commandargs.UnmanagedObject, m_ResultBuf)

        commandargs.Dispose()
        If m_Return &amp;lt;&amp;gt; 5100 Then
            MsgBox(String.Format("Return value {0}", m_Return))
        End If
    End Sub

    &amp;lt;DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acedInvoke")&amp;gt; _
    Private Shared Function acedInvoke(ByVal args As IntPtr, ByRef result As IntPtr) As Integer
    End Function


End Class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As I've noted in the Lisp code, the Visual Lisp code to add text is working but the command line version does not, it returns "invalid AutoCAD command:".&lt;/P&gt;&lt;P&gt;Am I doing something wrong or does "command" not work when the lisp is called from dot net?&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 13:22:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3451896#M55654</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2012-05-10T13:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3452072#M55655</link>
      <description>&lt;P&gt;To call LISP functions via acedInvoke, they must be registered using (vl-acad-defun)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://forums.autodesk.com/t5/NET/loading-a-lisp-with-dot-net-wizard/m-p/3083852#M24238" target="_blank"&gt;http://forums.autodesk.com/t5/NET/loading-a-lisp-with-dot-net-wizard/m-p/3083852#M24238&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 14:31:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3452072#M55655</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-10T14:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3452998#M55656</link>
      <description>&lt;P&gt;Oops! I see that you use command attribute &lt;EM&gt;&lt;STRONG&gt;CommandFlags.Session&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;(command ...) as far as acedCommand() and acedCmd() can not been called from Application context.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 20:49:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3452998#M55656</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-10T20:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455722#M55657</link>
      <description>&lt;P&gt;Thank you for the replies.&lt;/P&gt;&lt;P&gt;So is there NO way to use "command" in a Lisp function that is called from Dot Net?&lt;/P&gt;&lt;P&gt;Or do I have something wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2012 10:41:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455722#M55657</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2012-05-14T10:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455744#M55658</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/336009"&gt;@jshimkus&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So is there NO way to use "command" in a Lisp function that is called from Dot Net?&lt;/P&gt;
&lt;P&gt;Or do I have something wrong?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Change &lt;EM&gt;&lt;STRONG&gt;CommandFlags.Session &lt;/STRONG&gt;&lt;/EM&gt;with&lt;STRONG&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;CommandFlags.Modal&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt; in your's VB.NET code and try again.&lt;EM&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2012 10:55:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455744#M55658</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-14T10:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455774#M55659</link>
      <description>&lt;P&gt;Thanks, that works for my simple example that I posted.&lt;/P&gt;&lt;P&gt;But what I am really trying to do is this.&lt;/P&gt;&lt;P&gt;I have a command method that opens and closes multiple drawings (has to be "Session" right?), when certain drawings are open I want to run a Lisp program in them, and that Lisp program contains "command" functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So while the Session command method is running can I call a Modal command method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2012 11:33:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455774#M55659</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2012-05-14T11:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455784#M55660</link>
      <description>&lt;P&gt;IMHO. You can make two .NET command. One with Session flag, other with Modal flag.&lt;/P&gt;
&lt;P&gt;First command open/close dwg-file and start (with Document.SendStringToExecute method, or IAcadDocument.SendCommand method) second command, which call Lisp.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2012 11:57:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455784#M55660</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-14T11:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455812#M55661</link>
      <description>&lt;P&gt;Thanks! You've been a big help, I will give that a try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One last question, can both of the command methods be in the same class?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2012 12:02:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455812#M55661</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2012-05-14T12:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455816#M55662</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;CommCorp wrote: &lt;BR /&gt;
&lt;P&gt;[...]One last question, can both of the command methods be in the same class?[...]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. &lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2012 12:04:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3455816#M55662</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-14T12:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is Lisp "command" function not available when called from VB Dot N</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3458044#M55663</link>
      <description>&lt;P&gt;Sorry to bother you again but I have attempted to implement your suggestions but it still is not quite working for me.&lt;/P&gt;&lt;P&gt;Close, but not quite. The program is opening the new drawing, and I can tell that it tries to execute the Lisp program because the command line says "Command: runlisp", but then it errors out with a "Fatal Error unhandled access violation". I cant' use "sendstringtoexecute" as you suggested because that does not run until the DotNet program has finished and at that point the drawings ive created are long closed.&lt;/P&gt;&lt;P&gt;Attached is&amp;nbsp;an abbreviated, but more acurate,&amp;nbsp;code structure to show exactly what im trying to do.&lt;/P&gt;&lt;P&gt;Do you see what I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Class DwgGenerator

  &amp;lt;CommandMethod("DwgGen", CommandFlags.Session)&amp;gt; _
    Public Sub Get_Data()
	' figure which drawing to create and create it
	
		Create_constdwg(ConstFolder, DWGName, ConstLevel, progType, progFile, progCmnd, progExec)
	End Sub
	
	Public Sub Create_constdwg(ByVal ConstFolder As String, ByVal DWGName As String, ByVal ConstLevel As String, _
                               ByVal progType As String, ByVal progFile As String, ByVal progCmnd As String, ByVal progExec As String)
	   ' create the new drawing, open and set as active dwg. Then run the Lisp program in it.
          Try
            Dim newdoc As Document = myAcadApp.DocumentManager.Add(TemplateDwgFullPath)
            Using newdoc.LockDocument
                ' save it to its actual name
                newdoc.Database.SaveAs(ConstFolder &amp;amp; DWGName &amp;amp; ".dwg", DwgVersion.Current)
            End Using
            newdoc.CloseAndDiscard()

            'open the newly created construct and set as the active document
            newdoc = myAcadApp.DocumentManager.Open(ConstFolder &amp;amp; DWGName &amp;amp; ".dwg", False, "")
            Using newdoc.LockDocument
                myAcadApp.DocumentManager.MdiActiveDocument = newdoc
                ' launch the Lisp program.
                app.ActiveDocument.SendCommand("runlisp" &amp;amp; vbCr)
             End Using
            newdoc.CloseAndSave(ConstFolder &amp;amp; DWGName &amp;amp; ".dwg")

        Catch ex As System.Exception
            MessageBox.Show(ex.Message, "Construct create Error")
        End Try
							   
	End Sub
	
	&amp;lt;CommandMethod("runlisp", CommandFlags.Modal)&amp;gt; _
    Public Sub runlisp()
        Dim commandargs As New ResultBuffer()
        app.ActiveDocument.SendCommand("(load """ &amp;amp; progFile &amp;amp; """)" &amp;amp; vbCr)
        commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.Text, "c:netdrawshell"))
        commandargs.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(LispDataType.Text, "ceil"))

        Dim m_ResultBuf As IntPtr = IntPtr.Zero
        Dim m_Return As Integer = acedInvoke(commandargs.UnmanagedObject, m_ResultBuf)

        commandargs.Dispose()
        If m_Return &amp;lt;&amp;gt; 5100 Then
            MsgBox(String.Format("Return value {0}", m_Return))
        End If
    End Sub
	
	&amp;lt;DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acedInvoke")&amp;gt; _
    Private Shared Function acedInvoke(ByVal args As IntPtr, ByRef result As IntPtr) As Integer
    End Function
	
End Class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2012 15:13:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-lisp-quot-command-quot-function-not-available-when-called/m-p/3458044#M55663</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2012-05-15T15:13:13Z</dc:date>
    </item>
  </channel>
</rss>

