如何让用户取消我的 AutoCAD 命令

发布于 2024-09-16 16:26:20 字数 283 浏览 12 评论 0原文

我目前正在 Visual Basic(.Net 3.0、VisualStudio 2010)中开发 AutoCAD 2008 Addin。

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

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

HostApplicationServices.Current.UserBreak

方法。但在 ACAD 2008 中则不然。

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

I'm currently developing an AutoCAD 2008 Addin in Visual Basic (.Net 3.0, VisualStudio 2010).

I'm able to define my own command and I want the user to be able to cancel my command by hitting the ESC key.

In AutoCAD 2010 or higher there exists the

HostApplicationServices.Current.UserBreak

method. But not in ACAD 2008.

Does anyone has any suggestions, how the user may be able to cancel my command?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

翻身的咸鱼 2024-09-23 16:26:20

不确定这是否是您要找的,但我会把它扔在那里。在以下示例中,它提示用户输入并将其存储到 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()
        }
    }

Not sure if this is what your looking for, but I'll throw it out there. In the following example, it prompts the user for input and stores it to the getPointResult. If the user selects "Escape" at this time, the getPointResult.Status will not be PromptStatus.OK, therefor it will not execute the code in the 'if' statement.

Sorry, this is written in C#, but should be easy enough to understand the general idea.

[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()
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文