My question: why aren't these (inherited) methods and properties hidden/removed in class PromptStringOptions?The nature and advantage of inheritance and using base class is that method definitions don't need to be duplicated ... If they're defined in the base class then they are usable from the child class.
Where can I find out which inherited fields can/cannot be used in a given class?
[CommandMethod("prs")]
public static void testPrompts()
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
PromptStringOptions pso = new PromptStringOptions("\nEnter a string or choose from list [Alpha/Bravo/Charlie/Delta]: ");
pso.DefaultValue = "Alpha";
pso.UseDefaultValue = true;
pso.AppendKeywordsToMessage = true;
PromptResult pr = ed.GetString(pso);
ed.WriteMessage("\nChoosen: {0}",pr.StringResult);
PromptKeywordOptions pko = new PromptKeywordOptions("\nEnter a string or choose from list [Alpha/Bravo/Charlie/Delta]: ",
"Alpha Bravo Charlie Delta");
pko.Keywords.Default = "Alpha";
PromptResult res = ed.GetKeywords(pko);
ed.WriteMessage("\nChoosen: {0}",res.StringResult);
}
Just as an update, I've taken Jeff's code (thanks again!) and slightly revised the CommandMethod to suite our use, and I am posting it here in the event that others may be interested.
In short, I revised the Prompt*Options to allow me to incorporate a Keyword (our company name), which allows the user to simply Enter, rather than manually typing out the company name each-and-every-time a change is made.
Also, a special thanks to Hallex (aka Oleg), for his suggestion of using *.Keywords.AllowArbitraryInput = true; as a work around to allowing 'string' input, and Keyword options in this post (http://forums.autodesk.com/t5/NET/GetString-with-Keywords-FATAL-ERROR/td-p/3373735).
Here's the code, note the 'companyName' variable at the top of the Class... Simply change this value to your company name and recompile:Code - C#: [Select]
[CommandMethod("StylesCreatedBy")] public static void StylesCreatedBy() { // // Company name as string, to be used as default prompt option // String companyName = "SomeCompany"; //<-- Your company name goes here // Document acDoc = Application.DocumentManager.MdiActiveDocument; CivilDocument civDoc = CivilApplication.ActiveDocument; myOpts.Message = "\nEnter new value for 'Created By' in all styles or: "; // Define the valid keywords, specify default as 'companyName', // and allow arbitrary input (spaces not accepted) myOpts.Keywords.Add(companyName); myOpts.Keywords.Default = companyName; myOpts.AllowArbitraryInput = true; PromptResult myRes = acDoc.Editor.GetKeywords(myOpts); if (myRes.Status != PromptStatus.OK) return; using (tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { creator = myRes.StringResult; ListRoot(civDoc.Styles); tr.Commit(); } }
Cheers! :beer:
** Edit - Separately, I'd just like to point out how disappointed I am that .NET does not have an equivalent for:Code: [Select]_$ (setq var (getstring T "\nEnter a string or [Small/Medium/Large] <Large>: "))
"Something Else"
_$
... The idea of disallowing Keyword entry with GetString() Method is idiotic.
/vent