简体   繁体   English

从AutoCAD .NET编辑器调用LISP命令。

[英]Calling LISP command from AutoCAD .NET Editor.CommandAsync

I am attempting to call an inbuilt AutoCad Electrical LISP command "c:wd_insym2" from .NET. 我试图从.NET调用内置的AutoCad Electrical LISP命令"c:wd_insym2" I have recently installed AutoCad 2016 which now has the Editor.Command and Editor.CommandAsync functions, however all the help/forum posts that I can find refer to using it to call AutoCad commands such as LINE, CIRCLE etc. I want to call a lisp command, such as: 我最近安装了AutoCad 2016,它现在具有Editor.Command和Editor.CommandAsync函数,但是我可以找到的所有帮助/论坛帖子均涉及使用它来调用AutoCad命令,例如LINE,CIRCLE等。我想调用lisp命令,例如:

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

which inserts a pushbutton symbol at 0, 0 . 0, 0处插入按钮符号。

Here's what I've got (I have been using CommandAsync because I have had trouble sending that command synchronously using Application.Invoke before: AutoCad Command Rejected "Undo" when using Application.Invoke() 这就是我得到的(我一直在使用CommandAsync,因为之前在使用Application.Invoke同步发送该命令时遇到了麻烦: AutoCad命令在使用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

When I run it it says 'LISP command not available'. 当我运行它时,它说“ LISP命令不可用”。

Is what I'm doing possible, and if so, what am I doing wrong? 我正在做的事情有可能吗?如果可以,我做错了什么?

I sort of solved the issue - evidently you can't use Command and CommandAsync to run Lisp commands - they're only for AutoCAD commands. 我已经解决了这个问题-显然您不能使用Command和CommandAsync运行Lisp命令-它们仅适用于AutoCAD命令。

The best way of doing this is Application.Invoke: https://forums.autodesk.com/t5/net/unable-to-find-an-entry-point-in-dll-acad-exe/mp/5522036/highlight/true#M43404 最好的方法是Application.Invoke: https : //forums.autodesk.com/t5/net/unable-to-find-an-entry-point-in-dll-acad-exe/mp/5522036/highlight /真#M43404

Although, with my specific Electrical command (c:wd_insym2), when I try this technique in AutoCAD 2014, it gives me an error 'AutoCAD command rejected UNDO'. 尽管使用我的特定电子命令(c:wd_insym2),当我在AutoCAD 2014中尝试此技术时,它给我一个错误“ AutoCAD命令拒绝UNDO”。 However, I have just noticed that in AutoCAD 2016 it works fine - I guess they've changed the API somewhere along the line. 但是,我刚刚注意到在AutoCAD 2016中它可以正常工作-我想他们已经沿线更改了API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM