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.
Here's the code, note the 'companyName' variable at the top of the Class... Simply change this value to your company name and recompile:
[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;
PromptKeywordOptions myOpts
= new PromptKeywordOptions
(""); 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:
_$ (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