<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: promptselectionresult with change-able keywords in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13440858#M5843</link>
    <description>&lt;P&gt;yeah sorry 'loop' was not the right word used, there is no loop. I meant to say 'command'.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Apr 2025 18:22:22 GMT</pubDate>
    <dc:creator>stefanveurink68AXD</dc:creator>
    <dc:date>2025-04-23T18:22:22Z</dc:date>
    <item>
      <title>promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12513930#M5835</link>
      <description>&lt;P&gt;Hey, I want to get a selection from user, while giving the possibility to change certain 'variables' for the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With promptentityoptions i do this (simplified) like:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;string S_Scale = "Scale=1:" + D_Scale; 

PromptEntityOptions opt = new PromptEntityOptions("\nSelect");
string S_Scale = "Scale=1:" + D_Scale;
opt.Keywords.Add(S_Scale);

 PromptEntityResult res = ed.GetEntity(opt);
 if (res.Status == PromptStatus.OK)
 {}
 else if (res.Status == PromptStatus.Keyword)
 {
    if (res.StringResult == S_Scale)
    {
       PromptStringOptions pso = new PromptStringOptions("\nScale 1 op:");
       PromptResult res1 = ed.GetString(pso);
      DPSchaal = Convert.ToDouble(res1.StringResult)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, with promptselectionoptions, I don't seem to get into the "prompstatus.keyword when clicking/entering the keyword. Tried it these ways:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.keanw.com/2010/05/adding-keyword-handling-to-autocad-nets-getselection.html" target="_blank"&gt;https://www.keanw.com/2010/05/adding-keyword-handling-to-autocad-nets-getselection.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-94A4E3DE-0066-4D6A-8558-0252BE8CB85E" target="_blank"&gt;https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-94A4E3DE-0066-4D6A-8558-0252BE8CB85E&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but these don't seem to work either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to do what I want, or isn't this available? And if yes, how?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 19:32:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12513930#M5835</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2024-01-22T19:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12514207#M5836</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6508502"&gt;@stefanveurink68AXD&lt;/a&gt;&amp;nbsp;Show the code you tried based on Kean's example. It should work, as that is the way all of my selections with Keywords are handled.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 21:39:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12514207#M5836</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2024-01-22T21:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12515170#M5837</link>
      <description>&lt;LI-CODE lang="general"&gt;double Puntafstand = 0.5;

var PSopties = new PromptSelectionOptions();
string S_puntafstand = "MaxAfstand=" + Puntafstand.ToString();
PSopties.Keywords.Add(S_puntafstand);
           
string kws = PSopties.Keywords.GetDisplayString(true);
PSopties.MessageForAdding = "selecteer de punten en lijnen" + kws ;

PSopties.KeywordInput += delegate (object sender, SelectionTextInputEventArgs e)
            {
               string key = e.Input;
                if (key == S_puntafstand)
                {
                    PromptStringOptions pso = new PromptStringOptions("\nGeef maximale afstand:");
                    pso.AllowSpaces = false;
                    PromptResult res1 = edi.GetString(pso);

                    bool inputakkoord = true;
                    try
                    {
                        Puntafstand = Convert.ToDouble(res1.StringResult);
                        S_puntafstand = "MaxAfstand=" + Puntafstand.ToString();
                    }
                    catch
                    {
                        inputakkoord = false; 
                    }

                    if (inputakkoord == false)
                    {
                        MessageBox.Show("Dit is geen getal!"); 
                    }
                }

            };&lt;/LI-CODE&gt;&lt;P&gt;See above, I see the keyword, but it doesn't seem to get into the 'delegate code', I can't reach the 'string key = e.input" in my debugger.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 10:41:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12515170#M5837</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2024-01-23T10:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12516230#M5838</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6508502"&gt;@stefanveurink68AXD&lt;/a&gt;&amp;nbsp;you are confusing different selection types. GetEntity does not utilize the PromptSelectionOptions. Going back to the original code you posted, something like this is more of what you will be needing.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;        [CommandMethod("LetsTestThis")]
        public void letstestthis()
        {
            var D_Scale = 1.0;
            var DPSchaal = double.NaN;
            var doc = Application.DocumentManager.MdiActiveDocument;
            var ed = doc.Editor;
            PromptEntityOptions opt = new PromptEntityOptions("\nSelect");
            string S_Scale = "Scale=1:" + D_Scale.ToString("F0"); ;
            opt.Keywords.Add(S_Scale);
            opt.AppendKeywordsToMessage = true;
            PromptEntityResult res = ed.GetEntity(opt);
            while (res.Status == PromptStatus.Keyword)
            {
                if (res.StringResult == S_Scale)
                {
                    PromptDoubleOptions pso = new PromptDoubleOptions("\nScale 1 op:");
                    var res1 = ed.GetDouble(pso);
                    DPSchaal = res1.Value;
                    S_Scale = "Scale=1:" + res1.Value.ToString("F0");
                    opt.Keywords.Clear();
                    opt.Keywords.Add(S_Scale);
                    res = ed.GetEntity(opt);
                }
            }
            if (res.Status != PromptStatus.OK)
                return;
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 23 Jan 2024 19:22:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12516230#M5838</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2024-01-23T19:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12516314#M5839</link>
      <description>&lt;P&gt;Yes I understand that it works with getEntity, but then I can only select one entity. I want to select multiple, including filtering. If I understand you correct you say this is not possible? Didn't expect it to be such a difference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 20:06:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12516314#M5839</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2024-01-23T20:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12516522#M5840</link>
      <description>&lt;P&gt;Try testing your code with a relatively- simple test keyword rather than the one that you are using (that contains an equals sign). And, make sure that the keyword doesn't conflict with any of the keywords that are available at the select objects prompt. And see if that keyword works and if your Handler is being entered with it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 22:13:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/12516522#M5840</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-01-23T22:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13429779#M5841</link>
      <description>&lt;P&gt;Okay, got it kinda working now (including the "="-sign, also tried it without).&lt;/P&gt;&lt;P&gt;Only thing is I can't get the keywords to change dynamically. Like with the PromptEntityOptions.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;private SelectionSet bochten(string message)
{ 
            var PSopties = new PromptSelectionOptions();
            string S_Tol = D_tolerance.ToString();
            string S_Tolerance = "Tolerance=" + S_Tol;
            PSopties.Keywords.Add(S_Tolerance)
            
            string kws = PSopties.Keywords.GetDisplayString(true);
            PSopties.MessageForAdding = "Do selection or: " + kws;

            PSopties.KeywordInput += delegate (object sender, SelectionTextInputEventArgs e)
            {
                string key = e.Input;
                                           
                if (key == S_tolerance)
                {

                PromptStringOptions pso = new PromptStringOptions("\n set tolerance: ");
                    pso.AllowSpaces = false;
                    PromptResult res1 = edi.GetString(pso);

                    try
                    {
                        double b = Convert.ToDouble(res1.StringResult);
                        D_tolerance = b;
                        S_Tol = D_tolerance.ToString();
                        S_Tolerance = "Tolerance=" + S_Tol;
                        PSopties.Keywords.Clear();
                        PSopties.Keywords.Add(S_Tolerantie);
                        kws = PSopties.Keywords.GetDisplayString(true);
                        PSopties.MessageForAdding = "Do selection or: " + kws;
                    }
                    catch 
                    {
                        MessageBox.Show("input error");                     
                    }  
                 }
            }
}&lt;/LI-CODE&gt;&lt;P&gt;Tried different options. The keyword is changed, because when i break out of it (by pressing "esc" in autocad) and start it again, the keyword is updated.&lt;/P&gt;&lt;P&gt;But I can't get it working to break out of it within the code after changing the keyword. This would be not perfect, but acceptable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most perfect would be the keyword changing while still in the same loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 20:12:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13429779#M5841</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2025-04-16T20:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13429863#M5842</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6508502"&gt;@stefanveurink68AXD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Okay, got it kinda working now (including the "="-sign, also tried it without).&lt;/P&gt;&lt;P&gt;Only thing is I can't get the keywords to change dynamically. Like with the PromptEntityOptions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried different options. The keyword is changed, because when i break out of it (by pressing "esc" in autocad) and start it again, the keyword is updated.&lt;/P&gt;&lt;P&gt;But I can't get it working to break out of it within the code after changing the keyword. This would be not perfect, but acceptable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most perfect would be the keyword changing &lt;EM&gt;&lt;STRONG&gt;while still in the same loop&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I don't see any loop in the code you show above. If that code is being executed within a loop at an outer scope that's not shown, there is a new PromptSelectionOptions instance created on each loop iteration, and would explain why the keyword isn't changing on each prompt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you're calling GetSelection() in a loop, you have the pass the &lt;EM&gt;same instance&lt;/EM&gt; of the PromptSelectionOptions on each iteration, rather than creating a instance on each iteration.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2025 21:24:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13429863#M5842</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-16T21:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13440858#M5843</link>
      <description>&lt;P&gt;yeah sorry 'loop' was not the right word used, there is no loop. I meant to say 'command'.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 18:22:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13440858#M5843</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2025-04-23T18:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13441349#M5844</link>
      <description>&lt;P&gt;After looking at your code again the problem is that when the user r&lt;SPAN&gt;esponds with a keyword, the call to GetSelection() returns. That means there &lt;EM&gt;must&lt;/EM&gt; be a loop that calls GetSelection() on each iteration.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 01:12:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13441349#M5844</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-24T01:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13442771#M5845</link>
      <description>&lt;P&gt;Yes okay, I see what you mean, but problem is, in contrary to SelectEntity, i have to put the delegate before the GetSelection, so you never enter the 'else' part other then from breaking out of the 'command'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;private SelectionSet bochten(string message)
{ 
  while(true)
  {
            //you only reach this place one time, not looping. 

            var PSopties = new PromptSelectionOptions();
            string S_Tol = D_tolerance.ToString();
            string S_Tolerance = "Tolerance=" + S_Tol;
            PSopties.Keywords.Add(S_Tolerance)
            
            string kws = PSopties.Keywords.GetDisplayString(true);
            PSopties.MessageForAdding = "Do selection or: " + kws;

            PSopties.KeywordInput += delegate (object sender, SelectionTextInputEventArgs e)
            {
                string key = e.Input;
                                           
                if (key == S_tolerance)
                {

                PromptStringOptions pso = new PromptStringOptions("\n set tolerance: ");
                    pso.AllowSpaces = false;
                    PromptResult res1 = edi.GetString(pso);

                    try
                    {
                        double b = Convert.ToDouble(res1.StringResult);
                        D_tolerance = b;
                        S_Tol = D_tolerance.ToString();
                        S_Tolerance = "Tolerance=" + S_Tol;
                        PSopties.Keywords.Clear();
                        PSopties.Keywords.Add(S_Tolerantie);
                        kws = PSopties.Keywords.GetDisplayString(true);
                        PSopties.MessageForAdding = "Do selection or: " + kws;
                    }
                    catch 
                    {
                        MessageBox.Show("input error");                     
                    }  
                 }
            }

                PromptSelectionResult res = edi.GetSelection(PSopties, filter);
                if (res.Status == PromptStatus.OK)
                {
                    SelectionSet set = res.Value;
                    return set;
                }
                else 
                {
                
                
                
                }
               

  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Apr 2025 17:52:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13442771#M5845</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2025-04-24T17:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13443204#M5846</link>
      <description>&lt;P&gt;After looking at the disassembled code for GetSelection() it doesn't appear that there is any way to change the keywords after GetSelection() is called. The keyword event handler is called from native code, and that code will continue to issue prompts for selection as long as a keyword is entered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, what I wrote above is not true. GetSelection() doesn't return when you enter a keyword, it calls the keyword event handler and then reissues the prompt for input, and the keywords cannot be changed. The only way to exit the call to GetSelection() is to supply another type of response (select objects, or cancel/esc).&amp;nbsp; I would call that a deficiency in the design as changing keywords and optionally exiting the internal loop are legitimate requirements in certain use cases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way I can find to exit the call to GetSelection() when a Keyword is entered, is to throw an exception from the keyword input event handler, and catch it in the code that calls GetSelection().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static class PromptSelectionWithKeyword
{
   public static PromptSelectionResult GetSelectionWithKeywords(this Editor editor, params string[] keywords)
   {
      string keyword = null;
      int i = 0;
      PromptSelectionOptions pso = new PromptSelectionOptions();
      pso.KeywordInput += OnKeywordInput;
      foreach(string s in keywords)
         pso.Keywords.Add(s);
      pso.Keywords.Add("Quit");
      pso.Keywords.Add("Change");

      void OnKeywordInput(object sender, SelectionTextInputEventArgs e)
      {
         keyword = e.Input;
         if(e.Input == "Quit" || e.Input == "Change")
            throw new KeywordException(e.Input); // break out of loop

         // Otherwise, prompt is repeated with the same keywords.
      }

      PromptSelectionResult result = null;

      while(true)
      {
         try
         {
            result = editor.GetSelection(pso);
         }
         catch(KeywordException ex)
         {
            editor.WriteMessage($"\nKeyword input: {ex.Keyword}");
            if(ex.Keyword == "Quit")
            {
               return null; // Can't return PromptSelectionResult
            }
            else if(ex.Keyword == "Change")
            { 
               /// Modify/add/remove keywords here
               pso.Keywords.Add("NewKeyword");
            }
            continue;
         }
         return result;
      }
   }

   public class KeywordException : System.Exception
   {
      string keyword;
      public KeywordException(string keyword)
      {
         this.keyword = keyword;
      }

      public string Keyword =&amp;gt; keyword;
   }

   [CommandMethod("SELECTWITHKEYWORDS")]
   public static void Test()
   {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor editor = doc.Editor;
      var psr = editor.GetSelectionWithKeywords("FIrst", "Second", "Third");
      if(psr == null)
         editor.WriteMessage("\nUser chose Quit");
      else
         editor.WriteMessage($"\nresult.Status = {psr.Status}");
   }

}
&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 25 Apr 2025 00:52:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13443204#M5846</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-25T00:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13444532#M5847</link>
      <description>&lt;P&gt;Yeah, since delegate has to be defined before promptselection, and promptselection has to be defined before loop, I tried to change the delegate in the&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if (res.Status == PromptStatus.Keyword)
  {
    //here       
  }&lt;/LI-CODE&gt;&lt;P&gt;but isn't working either. Probably because delegate is not changing if PromptSelection isn't finished yet. Little weird but okay.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you test your code? Because when I do I don't see any keywords appearing at all... to be honest nothing really happens (seems to). You just can do a selection, but nothing with keywords?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 13:21:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13444532#M5847</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2025-04-25T13:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13445161#M5848</link>
      <description>&lt;P&gt;Perhaps I didn't explain clearly enough. The code I posted works, but you may have been expecting it to do something it wasn't intended to do. It only shows how to call GetSelection() in a loop, and exit the loop when the user enters a keyword, by using an exception, and also shows how to add another keyword to the prompt. To change the keywords, you must exit the inner loop by throwing the exception. When it's caught you can then modify the keywords.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It might also help to point out that once GetSelection() is called, and up to the point when it returns, the PromptSelectionOptions you pass to it, is &lt;EM&gt;effectively read only, &lt;/EM&gt;and&amp;nbsp;any changes made to it from within a keyword input event handler will be ignored until the PromptSelectonOptions is again passed into a subsequent call to GetSelection().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words there are &lt;EM&gt;two&lt;/EM&gt; loops. One is the loop within GetSelection() that iterates each time the user responds with a keyword. The only way to exit that internal loop is by throwing an exception that is caught within the &lt;EM&gt;outer loop.&lt;/EM&gt; The other "outer" loop repeatedly calls GetSelection() with the same PromptSelectionOptions, which it can modify before each call to GetSelection() (e.g., to add/change/remove keywords).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a slightly-more verbose version of the same code posted above, that displays a message each time you enter a keyword. Two of the keywords will exit the inner loop within GetSelection(), the "Change" keyword when entered, will add another keyword to the input prompt. The "Quit" keyword will exit both the inner and outer loops and return null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static class PromptSelectionWithKeyword
{
   public static PromptSelectionResult GetSelectionWithKeywords(this Editor editor, params string[] keywords)
   {
      string keyword = null;
      int i = 0;
      PromptSelectionOptions pso = new PromptSelectionOptions();
      pso.KeywordInput += OnKeywordInput;
      foreach(string s in keywords)
         pso.Keywords.Add(s);
      pso.Keywords.Add("Quit");
      pso.Keywords.Add("Change");

      void OnKeywordInput(object sender, SelectionTextInputEventArgs e)
      {
         keyword = e.Input;
         editor.WriteMessage($"User entered keyword {e.Input}");
         if(e.Input == "Quit" || e.Input == "Change")
            throw new KeywordException(e.Input); // break out of inner loop

         // Otherwise, Select Objects: prompt is re-issued
         // with the same keywords.
      }

      PromptSelectionResult result = null;

      while(true)
      {
         try
         {
            string suffix = pso.Keywords.GetDisplayString(true);
            pso.MessageForAdding = $"\nSelect objects or {suffix}";
            result = editor.GetSelection(pso);
         }
         catch(KeywordException ex)
         {
            editor.WriteMessage($"\nGetSelection() exited, keyword = {ex.Keyword}");
            if(ex.Keyword == "Quit")
            {
               return null; // Can't return PromptSelectionResult
            }
            else if(ex.Keyword == "Change")
            { 
               /// Modify/add/remove keywords here
               pso.Keywords.Add("NewKeyword");
            }
            continue;
         }
         return result;
      }
   }

   public class KeywordException : System.Exception
   {
      string keyword;
      public KeywordException(string keyword)
      {
         this.keyword = keyword;
      }

      public string Keyword =&amp;gt; keyword;
   }

   [CommandMethod("SELECTWITHKEYWORDS")]
   public static void Test()
   {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor editor = doc.Editor;
      var psr = editor.GetSelectionWithKeywords("FIrst", "Second", "Third");
      if(psr == null)
         editor.WriteMessage("\nUser chose Quit");
      else
         editor.WriteMessage($"\nresult.Status = {psr.Status}");
   }

}&lt;/LI-CODE&gt;&lt;P&gt;And here's what happens when I run it:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Command: SELECTWITHKEYWORDS

Select objects or [FIrst/Second/Third/Quit/Change]: First
User entered keyword FIrst

Select objects or [FIrst/Second/Third/Quit/Change]: Second
User entered keyword Second

Select objects or [FIrst/Second/Third/Quit/Change]: Change
User entered keyword Change
GetSelection() exited, keyword = Change

Select objects or [FIrst/Second/Third/Quit/Change/NewKeyword]: NewKeyword
User entered keyword NewKeyword

Select objects or [FIrst/Second/Third/Quit/Change/NewKeyword]: quit
User entered keyword Quit
GetSelection() exited, keyword = Quit
User chose Quit
Command:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 20:17:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13445161#M5848</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-25T20:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13604430#M5849</link>
      <description>&lt;P&gt;Well, I see what you are trying to do, but when I run it it doesn't work.... it does everything you say, only when I choose 'change'&amp;nbsp; it just gives me the option to select, nothing else happens. Others are the same as you posted above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only difference might be I'm calling it from another class (toolpallete). But I don't see how that should matter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll work on it, any ideas are welcome..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 19:18:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13604430#M5849</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2025-04-28T19:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13604451#M5850</link>
      <description>&lt;P&gt;The calling context most certainly does matter. If you are calling it from the application context such as from The Click Handler of a button on a tool pallet or something like that then it may not behave the way it will when called from the Handler of a registered command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I generally avoid executing code from the application context and instead place the code in a registered command Handler and then just execute the command from the application context.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 19:43:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13604451#M5850</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-28T19:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13604816#M5851</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6508502"&gt;@stefanveurink68AXD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only difference might be I'm calling it from another class (toolpallete). But I don't see how that should matter.&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;I'm not sure if you copied the code verbatim or not, but I just checked and the code I posted works from any calling context. E.g., from the click handler of a button on a Palette (application context), or from the registered command handler (document context).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the click handler of a button (application context):&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Select objects or [FIrst/Second/Third/Quit/Change]: first
User entered keyword 'FIrst'
Select objects or [FIrst/Second/Third/Quit/Change]: second
User entered keyword 'Second'
Select objects or [FIrst/Second/Third/Quit/Change]: change
User entered keyword 'Change'
GetSelection() exited, keyword = 'Change'
Select objects or [FIrst/Second/Third/Quit/Change/NewKeyword]: newkeyword
User entered keyword 'NewKeyword'
Select objects or [FIrst/Second/Third/Quit/Change/NewKeyword]: quit
User entered keyword 'Quit'
GetSelection() exited, keyword = 'Quit'
User chose Quit&lt;/LI-CODE&gt;&lt;P&gt;So, unless there's some difference in the code you're using, then the only other possibility is the AutoCAD release you're running on. There have been subtle changes over the last 3 or 4 major releases.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 02:22:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13604816#M5851</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-29T02:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13605292#M5852</link>
      <description>&lt;P&gt;Im running it at autocad 2024, .net-framework is 4.8.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will try some things when I got time, but i litteraly just pasted your code into mine, so i'm 100% it's exactly the same&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 09:25:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13605292#M5852</guid>
      <dc:creator>stefanveurink68AXD</dc:creator>
      <dc:date>2025-04-29T09:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: promptselectionresult with change-able keywords</title>
      <link>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13606110#M5853</link>
      <description>&lt;P&gt;Have you tried running the command that's included in the code that I posted?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 17:21:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/promptselectionresult-with-change-able-keywords/m-p/13606110#M5853</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-04-29T17:21:53Z</dc:date>
    </item>
  </channel>
</rss>

