【问题标题】:Autocad .NET - expand command lineAutocad .NET - 扩展命令行
【发布时间】:2021-06-16 16:05:18
【问题描述】:

我正在开发一个 Autocad .NET 插件(.dll 通过 NETLOAD 加载),并且我大量使用 Document.Editor 对象来获取用户输入,例如字符串、数字、点和实体。

我希望我的一些提示显示几个选项供用户选择(与原生 -DWGUNITS 命令完全一样)。

显示提示和选项非常好(我用Editor.GetInteger 来做,传递带有选项的多行消息,有时还有一两个关键字)。

但我不知道如何展开命令栏以使其显示所有选项(否则用户必须手动展开它才能看到列表)

所以,这是我目前的命令(蓝色的私人内容):

选项仅限于这三行(更改CLIPROMPTLINES 似乎不是最好的选择,但如果您知道如何使用.NET 来做,这是一个好的开始)。

.

这就是我想要的:

【问题讨论】:

  • 您是否尝试在 Autodesk 论坛上提出这个问题?全职 Autodesk 员工会不时在那里回答问题

标签: c# .net vb.net autocad autocad-plugin


【解决方案1】:

很简单,这个选项在Autodesk.Autocad.ApplicationServices.Application.DisplayTextScreen:

using Autodesk.Autocad.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;

private int AskUser(IEnumerable<string> userOptions)
{

        Document document= Application.DocumentManager.MdiActiveDocument;
        Editor editor = document.Editor;

        //Autocad's setting before you change
        bool originalSetting = CadApp.DisplayTextScreen;

        string message = "Available options:\n";
        message += string.join("\n",
            userOptions.Select((opt,i)=>i.ToString() + ": " + opt));
        message += "\nChoose an option"

        PromptIntegerOptions promptOptions = new PromptIntegerOptions(message);
        promptOptions.LowerLimit = 0;
        promptOptions.UpperLimit = userOptions.Count - 1;

        //display full command bar
        Application.DisplayTextScreen = true;
        var result = editor.GetInteger(promptOptions);

        int selection;
        if (result.Status == PromptStatus.OK)
            selection = result.Value;
        else
            selection = -1;

        //restore original setting
        Application.DisplayTextScreen = originalSetting;

        return selection;
}

【讨论】:

    猜你喜欢
    • 2013-06-25
    • 2015-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    相关资源
    最近更新 更多