从 AutoCAD .NET 调用 LISP 命令 Editor.CommandAsync

Calling LISP command from AutoCAD .NET Editor.CommandAsync

我正在尝试从 .NET 调用内置的 AutoCad Electrical LISP 命令 "c:wd_insym2"。 我最近安装了 AutoCad 2016,它现在具有 Editor.Command 和 Editor.Command 异步功能,但是我能找到的所有 help/forum 帖子都提到使用它来调用 AutoCad 命令,例如 LINE、CIRCLE等等 我想调用一个lisp命令,比如:

(c:wd_insym2 "HPB11.dwg" (list 0 0) 1.0 nil)

0, 0 处插入一个按钮符号。

这是我得到的(我一直在使用 CommandAsync,因为我之前在使用 Application.Invoke 同步发送该命令时遇到了问题:

<CommandMethod("SendCmdAsync", CommandFlags.Modal)>
Async Sub SendCmdAsync()
    Dim doc As Document = DocumentManager.MdiActiveDocument
    Dim ed As Editor = doc.Editor
    Dim cmd As String = "(c:wd_insym2 " & ControlChars.Quote & "HPB11.dwg" & ControlChars.Quote & " (list 0 0) nil nil)"
    ed.WriteMessage(vbNewLine & "Trying to execute: <" & cmd & ">" & vbNewLine)
    Await ed.CommandAsync(cmd)
    ed.WriteMessage(vbNewLine & "Done.")
End Sub

当我 运行 它说 'LISP command not available'.

我正在做的事情可行吗?如果可行,我做错了什么?

我有点解决了这个问题 - 显然你不能将 Command 和 CommandAsync 用于 运行 Lisp 命令 - 它们仅适用于 AutoCAD 命令。

最好的方法是Application.Invoke:https://forums.autodesk.com/t5/net/unable-to-find-an-entry-point-in-dll-acad-exe/m-p/5522036/highlight/true#M43404

虽然,使用我的特定电气命令 (c:wd_insym2),当我在 AutoCAD 2014 中尝试此技术时,它给我一个错误 'AutoCAD command rejected UNDO'。但是,我刚刚注意到在 AutoCAD 2016 中它工作正常 - 我猜他们已经更改了 API 沿线的某个地方。