Dan*_*ler 5 .net c# vb.net autocad autocad-plugin
我正在开发一个 Autocad .NET 插件(.dll通过加载NETLOAD),我使用了很多Document.Editor对象来获取用户输入,比如字符串、数字、点和实体。
我希望我的一些提示显示几个选项供用户选择(与本机-DWGUNITS命令完全一样)。
显示提示和选项非常好(我使用的是Editor.GetInteger,传递带有选项的多行消息,有时还有一两个关键字)。
但我无法弄清楚如何展开命令栏以使其显示所有选项(否则用户必须手动展开它才能查看列表)
所以,这是我目前的命令(蓝色的私人内容):
选项仅限于这三行(更改CLIPROMPTLINES似乎不是最好的选择,但如果您知道如何使用.NET,这是一个好的开始)。

.
这就是我想要的:
这很简单,这个选项位于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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |