2

我目前正在用 Visual Basic(.Net 3.0、VisualStudio 2010)开发一个 AutoCAD 2008 插件。

我能够定义我自己的命令,并且我希望用户能够通过按 ESC 键来取消我的命令。

在 AutoCAD 2010 或更高版本中,存在

HostApplicationServices.Current.UserBreak

方法。但不是在 ACAD 2008 中。

有没有人有任何建议,用户如何能够取消我的命令?

4

1 回答 1

1

不确定这是否是您要找的东西,但我会把它扔在那里。在以下示例中,它提示用户输入并将其存储到 getPointResult。如果此时用户选择“Escape”,getPointResult.Status 将不是 PromptStatus.OK,因此不会执行 'if' 语句中的代码。

抱歉,这是用 C# 编写的,但应该很容易理解总体思路。

[CommandMethod("test", CommandFlags.Session)]
    public void Test()
    {
        PromptPointOptions getPointOptions = new PromptPointOptions("Select the top-left location for the view: ");
        Document currentDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
        PromptPointResult getPointResult = currentDocument.Editor.GetPoint(getPointOptions);

        if (getPointResult.Status == PromptStatus.OK)
        {
            //Do work
        }
        else
        {
            //what to do if 'ESC' is pressed during GetPoint()
        }
    }
于 2010-11-09T14:10:18.430 回答