Let's see what user will think and do after seeing the prompt "Please select block or [Set value] <30>":
Firstly, the prompt is from PromptEntityOption used in Editor.GetEntity() call, right? User will
1. go ahead with mouse to pick block/entity;
2. or, user enter "s" for keywork "Set", which will be followed a prompt to ask user to enter a number (call Editor.GetInterger()/GetDouble()
3. or, user simply hit Enter/Space for default keywork, so that a value of 30 is assumed.
Since you do not want to present "30" as a keywork option to user, you can build the keyword as needed (i.e. add "30" as keyword and set it as default) and set PromptEntityOption.AppendKeywordToMessage to false (default value is true). This way you use the "Message" to build the fake keyword list you want user to see, and the invisible keyword list and its default still works as it should.
Here is the code:
[CommandMethod("MyPick")]
public static void RunMyCommand()
{
Document dwg = Application.DocumentManager.MdiActiveDocument;
Editor ed = dwg.Editor;
int val = 0;
ObjectId pickedId = ObjectId.Null;
while (true)
{
PromptEntityOptions opt = new PromptEntityOptions(
"\nSelect an entity or [Set value] <30>:");
opt.AllowNone = true;
opt.Keywords.Add("Set value");
opt.Keywords.Add("30");
opt.Keywords.Default = "30";
opt.AppendKeywordsToMessage = false;
PromptEntityResult res = ed.GetEntity(opt);
if (res.Status == PromptStatus.OK)
{
ed.WriteMessage("\nPicked entity: {0}", res.ObjectId.ToString());
pickedId = res.ObjectId;
break;
}
else if (res.Status == PromptStatus.Keyword)
{
ed.WriteMessage("keyword: {0}", res.StringResult);
if (res.StringResult == "Set")
{
//use Editor.GetInteger() tp get new value
//val=....
}
else
{
val = 30;
}
}
else
{
ed.WriteMessage("\nInvalid pick or cancelled");
break;
}
}
if (pickedId != ObjectId.Null)
{
//Do something
}
Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
}
}