2

現在、Visual Basic (.Net 3.0、VisualStudio 2010) で AutoCAD 2008 アドインを開発しています。

私は独自のコマンドを定義することができ、ユーザーが ESC キーを押してコマンドをキャンセルできるようにしたいと考えています。

AutoCAD 2010 以降には、

HostApplicationServices.Current.UserBreak

方法。ただし、ACAD 2008 にはありません。

ユーザーがコマンドをキャンセルする方法を教えてください。

4

1 に答える 1

1

これがあなたが探しているものであるかどうかはわかりませんが、私はそれをそこに投げます。次の例では、ユーザーに入力を求め、getPointResultに保存します。この時点でユーザーが「エスケープ」を選択した場合、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 に答える