2015-12-16 71 views
1

我試圖從.NET調用內置的AutoCad Electrical LISP命令"c:wd_insym2"。 我最近安裝了AutoCad 2016,它現在有Editor.Command和Editor.CommandAsync函數,但是我可以找到的所有幫助/論壇帖子都指向使用它調用LINE,CIRCLE等AutoCad命令。 我想調用一個lisp命令,如:從AutoCAD .NET調用LISP命令Editor.CommandAsync

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

它在0, 0處插入一個按鈕符號。

下面是我得到了什麼(我一直在使用CommandAsync因爲我有麻煩了發出這個命令之前同步使用Application.Invoke:AutoCad Command Rejected "Undo" when using 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命令不可用」

是我在做什麼可能的,如果是這樣,我在做什麼錯

回答

0

我有點解決了問題? - 顯然你不能用命令和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命令拒絕了UNDO'。不過,我剛剛注意到,在AutoCAD 2016中它工作正常 - 我猜他們已經改變了API的某處。