简体   繁体   English

Autocad .NET - 扩展命令行

[英]Autocad .NET - expand command line

I'm developing an Autocad .NET plugin ( .dll loaded via NETLOAD ), and I'm using a lot the Document.Editor object to get user inputs, like strings, numbers, points and entities.我正在开发一个 Autocad .NET 插件(通过NETLOAD加载的.dll ),并且我NETLOAD使用Document.Editor对象来获取用户输入,如字符串、数字、点和实体。

I want some of my prompts to show several options for the user to select (exactly as it happens with the native -DWGUNITS command).我希望我的一些提示显示几个选项供用户选择(就像使用本机-DWGUNITS命令一样)。

Displaying the prompt and the options is pretty ok (I'm doing it with an Editor.GetInteger , passing a multiline message with the options, and sometimes one or two keywords).显示提示和选项非常好(我用Editor.GetInteger ,传递带有选项的多行消息,有时还有一两个关键字)。

But I cannot figure out how to expand the command bar to make it show all the options (otherwise the user must manually expand it to see the list)但我无法弄清楚如何展开命令栏以使其显示所有选项(否则用户必须手动展开它才能查看列表)

So, here is my command currently (private content in blue):所以,这是我目前的命令(蓝色的私人内容):

The options are limited to these three lines (changing CLIPROMPTLINES doesn't seem the best option, but if you know how to do it with .NET , it's a good start).选项仅限于这三行(更改CLIPROMPTLINES似乎不是最好的选择,但如果您知道如何使用.NET来做,这是一个好的开始)。
这张图片代表我的命令

. .

And here is what I want:这就是我想要的:

此图像显示了预期的行为

It's simple and this option is in Autodesk.Autocad.ApplicationServices.Application.DisplayTextScreen :这很简单,此选项位于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;
}

I develop several plugins for Autodesk AutoCAD or Plant 3D and engaged to Autodesk Knowledge Forum (for .NET) for 3 years ( my Autodesk Knowledge profile ), and when I have some plugin requirement that SDK/API do not give the resources, I recurring to C# PInvoke API ;我为 Autodesk AutoCAD 或 Plant 3D 开发了几个插件,并在Autodesk 知识论坛(.NET)工作了 3 年( 我的 Autodesk 知识档案),当我有一些插件要求 SDK/API 不提供资源时,我经常到C# PInvoke API with this certainly you will change User Interface behavior that you need, using Spy++ to get the metadata of AutoCAD UI component, and set the updates that needs to do.有了这个,你肯定会改变你需要的用户界面行为,使用 Spy++ 获取 AutoCAD UI 组件的元数据,并设置需要做的更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM