.NET

Reply
Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 1 of 5 (327 Views)
Accepted Solution

AutoCAD command prompt

327 Views, 4 Replies
03-28-2014 08:39 PM

How to display the prompt on the AutoCAD command line in the following format


For example:
Chose one option[Apple(A), Pear(P)] <A>:

 

Chose one option: this part is the description, it give information to users

 

[Apple(A), Pear(P)] : this part is the keywords list that allowed to choose
Note: the format I required inculde the full words and the first character of the words, as well as brackets and parentheses

 

<A>: this part is the default keyword

 

Input A will choose the Apple, Input P will choose the Pear

 

Is the anyone can give me a example? very thanks

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 5 (309 Views)

Re: AutoCAD command prompt

03-28-2014 10:39 PM in reply to: HelloWorlddd

Try this quick example

      [CommandMethod("kws")]
        public void testKeyWords()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            PromptKeywordOptions pko = new PromptKeywordOptions("\nChose one option [Apple/Pear]: ", "Apple Pear");
            // The default depends on our current settings
            pko.Keywords.Default = "Apple";
            PromptResult pres = ed.GetKeywords(pko);
            if (pres.Status != PromptStatus.OK)
                return;

            string choice = pres.StringResult;
            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Choosen: " + choice);
        }

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 3 of 5 (302 Views)

Re: AutoCAD command prompt

03-29-2014 12:49 AM in reply to: Hallex

Thans for your help, but it didn't work as my want, below is your example code run result:

capture.PNG

 

The goal which I want is will like below:


Choose one option [Apple(A)/Pear(P)] <A>:

 

I think the above format will be more readable for users, is there exsit some solution can achieve this format?
Very thanks

*Expert Elite*
norman.yuan
Posts: 980
Registered: ‎04-27-2009
Message 4 of 5 (286 Views)

Re: AutoCAD command prompt

03-29-2014 07:41 AM in reply to: HelloWorlddd

Well, your intention is quite obviously to let user know to press "A" in the bracket for "Apple". Good try, but it is NOT necessary and NOT somethnign that follows AutoCAD command convention. ALL AutoCAD USERS should/must know that the capital letter in a keyword is the letter they need to press the key to select. They should not be prompted with another capital letter in bracket beside the keyword. For example, if the keyword list has more than one keywords beginning with the same letter. such as "Apple", "Amber", then the the keyword list can be [Apple/aMber], so user should know to press "m" to select "Amber".

 

It is never a good practice to invent something that is against well known convention.

 

On the other hand, if you insist your unique requirement to your Auto\cad users, you can create the keyword like this "apple(A)", "pear(P)". That is in each keyword string, you have one unique capital letter or unique consecutive capital letters. this way the prompt at command lien would be:

 

"Choose option: [apple(A)/pear(P)] "

Valued Contributor
HelloWorlddd
Posts: 87
Registered: ‎05-03-2013
Message 5 of 5 (276 Views)

Re: AutoCAD command prompt

03-29-2014 09:43 AM in reply to: norman.yuan

Thanks for your suggestion

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.