2015-04-23 31 views
2

我一直在嘗試過去3周才能以編程方式調用undo命令。我最近的嘗試涉及從C#調用LISP代碼。現在我的C#方法看起來像這樣AutoCAD命令被拒絕:當從LISP調用undo時「撤消」

[CommandMethod("TestLispFromC#", CommandFlags.Modal)] 
    public void TestLisp() 
    { 
     ResultBuffer lispFunctionCallWithArguments = new ResultBuffer(new TypedValue((int)LispDataType.Text, "BIGUNDO")); // build the arguments list 
     ResultBuffer resultOfLispFunction = Autodesk.AutoCAD.ApplicationServices.Application.Invoke(lispFunctionCallWithArguments); // call the LISP fuction anf get the return value 
     _editor.WriteMessage(resultOfLispFunction.ToString()); //print the result 
    } 

而且Lisp的功能,我想援引來自這裏

(defun定義BIGUNDO() (命令 「撤消」, 「B」) )

(defun定義MARKPOS() (命令 「撤消」 的 「m」) )

(VL-ACAD-defun定義「BIGUNDO)

(vl-acad-defun'MARKPOS)

該命令使它成爲AutoCAD,但我遇到一個錯誤,說「AutoCAD命令被拒絕:」撤消「」。我不知道如何讓AutoCAD接受編程撤消命令。

回答

1

您需要使用C中定義:

請嘗試以下方法:

(defun定義C:BIGUNDO()(命令 「撤消」, 「B」, 「Y」))

注意結尾處的「Y」,因爲它詢問這將撤銷所有內容。好?

相關問題