上次飞狐版主提供一个C#调用lisp的程序,如下:- [CommandMethod("tt")] public static void Test() { var db = HostApplicationServices.WorkingDatabase; var doc = Application.DocumentManager.GetDocument(db); var ed = doc.Editor; var rb = InvokeArx.CallLispFunction("C:lsptest1"); ed.WriteMessage("{0}", rb); }
这个程序作为命令的形式运行良好。但是我把这段话写到我的窗体中时(如下),该窗体在AutoCAD中以ShowModelessDialog形式抛出,就运行不了啦。提示:invalid AutoCAD command: nil(我的lisp程序中调用了其他lisp程序)。但是我此时直接调用该lisp程序“test”运行良好。不知道这是怎么回事。 - private void button1_Click(object sender, EventArgs e)
- {
- var db = HostApplicationServices.WorkingDatabase;
- var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db);
- var ed = doc.Editor;
- var rb = InvokeArx.CallLispFunction("C:test");
- ed.WriteMessage("{0}", rb);
- }
|