.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCAD command prompt

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
HelloWorlddd
2652 Views, 4 Replies

AutoCAD command prompt

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

4 REPLIES 4
Message 2 of 5
Hallex
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
Message 3 of 5
HelloWorlddd
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

Message 4 of 5
norman.yuan
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)] "

Message 5 of 5
HelloWorlddd
in reply to: norman.yuan

Thanks for your suggestion

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost