马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Calling Lisp function using acedInvoke
问题:
I am using acedInvoke to call a Lisp function but I get a return value that equals RTERROR (5001). What am I missing ?
解答:
The Lisp function must be defined as a command as shown here :
- ;;; (defun DoIt() Define the Lisp function as a command using c:
- (defun c:DoIt()
- (setq pntA (getpoint "\nPick A")
- pntB (getpoint pntA "\nPick B")
- )
- (grdraw pntA pntB 1 2)
- )
Here is the sample code to call the Lisp command using acedInvoke :
- <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acedInvoke")> _
- Private Shared Function acedInvoke(ByVal args As IntPtr, ByRef result As IntPtr) As Integer
- End Function
- . . .
- Dim m_args As New Autodesk.AutoCAD.DatabaseServices.ResultBuffer()
- 'Returns RTERROR (5001)
- 'm_args.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(5005, "DoIt"))
- 'Returns RTNORM (5100)
- m_args.Add(New Autodesk.AutoCAD.DatabaseServices.TypedValue(5005, "c:DoIt"))
- Dim m_ResultBuf As IntPtr = IntPtr.Zero
- Dim m_Return As Integer = acedInvoke(m_args.UnmanagedObject, m_ResultBuf)
- m_args.Dispose()
- MsgBox(String.Format("Return value {0}", m_Return))
|