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.
I want some of my prompts to show several options for the user to select (exactly as it happens with the native -DWGUNITS
command).
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).
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).
.
And here is what I want:
It's simple and this option is in 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With