Message 1 of 10
Is Lisp "command" function not available when called from VB Dot Net?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to run a Lisp program by calling it from VB Dot Net.
Just for testing, my Lisp code is as follows...
(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) )
And my VB Dot Net code is...
ublic Class MyPlugin <CommandMethod("runlisp", CommandFlags.Session)> _ 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 <> 5100 Then MsgBox(String.Format("Return value {0}", m_Return)) End If End Sub <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acedInvoke")> _ Private Shared Function acedInvoke(ByVal args As IntPtr, ByRef result As IntPtr) As Integer End Function End Class
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:".
Am I doing something wrong or does "command" not work when the lisp is called from dot net?