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

Using Keywords

1 REPLY 1
Reply
Message 1 of 2
Fredrik.Larsen
1362 Views, 1 Reply

Using Keywords

Hi

 

I am trying to create a jig with keywords. The finctionality is working as I want to. My problem is that I have trouble setting all the keywords I want. I am using "SetMessageAndKeywords(string messageandkeyword, string globalkeywords)".

 

The exception I get is IndexOutOfRangeException even though I have verified that I have all the same keywords in both input parameters. I get it to work when I test with few keywords.

 

Are three any limitations for how many keywords I can have?

Are there illegal characters, must they all be regular characters a-z?

How does upper/lower case work?

1 REPLY 1
Message 2 of 2
Balaji_Ram
in reply to: Fredrik.Larsen

Hi Fredrik,

 

I have not seen any such documentation explaining the max limit or the list of acceptable characters.

If you can provide a sample code to reproduce the "IndexOutofrange" exception, I can try it at my end and see what might be causing it.

 

Just to test the basic keywords with alphabets / numbers and "?", I tried this code snippet and it worked ok.

This code uses about 39 keywords and it worked ok.

 

public class TestJig : EntityJig
{
    public TestJig() : base(new Autodesk.AutoCAD.DatabaseServices.DBPoint())
    {
    }

    protected override SamplerStatus Sampler(JigPrompts prompts)
    {
        JigPromptPointOptions jigOpts = new JigPromptPointOptions();

        jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates | 
                                    UserInputControls.NullResponseAccepted | 
                                    UserInputControls.NoNegativeResponseAccepted);

        string msgAndKwds = "\nSpecify a point or [A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/?/0/1/2/3/4/5/6/7/8/9/10/11]: ";

        string kwds = "Apple Box Cow Duck Eagle Fox Goat Hen Ink Jug Kangaroo Lion Moon Night Ox Peacock Quiet Rope Store Tank Umbrella Van Wax Xylophone Yak Zebra ?Help 00 10 20 30 40 50 60 70 80 90 100 110";

        jigOpts.SetMessageAndKeywords(msgAndKwds, kwds);
        PromptPointResult res = prompts.AcquirePoint(jigOpts);

        if (res.Status == PromptStatus.Keyword)
        {
            Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(String.Format("{0}Keyword : {1}", Environment.NewLine, res.StringResult));
            return SamplerStatus.OK;
        }
        else if (res.Status == PromptStatus.OK)
        {
            return SamplerStatus.OK;
        }
        return SamplerStatus.Cancel;
    }

    protected override bool Update()
    {
        return true;
    }

    [CommandMethod("TestJig")]
    public static void RunTestJig()
    {
        Document doc = Application.DocumentManager.MdiActiveDocument;
        Database db = doc.Database;
        Editor ed = doc.Editor;

        TestJig jig = new TestJig();

        while (true)
        {
            PromptResult res = ed.Drag(jig);
            switch (res.Status)
            {
                case PromptStatus.OK:
                    break;

                case PromptStatus.Keyword:
                    break;

                case PromptStatus.None:
                    return;

                default:
                    jig.Entity.Dispose();
                    return;
            }
        }
    }
} 

 

I am not sure what the upper limit is, but it might be confusing for the end-users if too many keywords are provided at once. You may want to accept a keyword and then provide another set of keywords based on the first input. For example : Accept the series name "M", "K" .... and then provide further keyword options such as "M10", "M20" if the keyword selected was "M".

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

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