Code Red > .NET

Combining a [Settings] Keyword with a .GetEntity call

(1/1)

ingenieur3d:
Hi!

I am trying to make my command even better by allowing access to user settings, but once the Keyword is used and the settings are changed the code returns after the .GetEntity call. Is there any way to gracefully return to my initial .GetEntity block of code?

My prompt message would be "Select a line or a polyline or [Settings]: "

Any help appreciated!


--- Code - C#: ---    pEntOpts = new PromptEntityOptions(Environment.NewLine + "Select a line or a polyline or : ")    { AllowNone = true , AppendKeywordsToMessage = true };    pEntOpts.SetRejectMessage(Environment.NewLine + "Your selection must be a line or a polyline.");    pEntOpts.Keywords.Add("Settings");     ...    // Ask the user to .GetEntity.    pEntRes = acDoc.Editor.GetEntity(pEntOpts);     if (pEntRes.Status == PromptStatus.Keyword)    {        // Change UserConfig        Interaction.UserConfig();         // What should I do here to make my code reinitiate???                    }    else if (pEntRes.Status != PromptStatus.OK)    {        // User leaves instead...        return;    } 

Jeff_M:
Here is one way:

--- Code - C#: ---            pEntRes = acDoc.Editor.GetEntity(pEntOpts);            do            {                // Change UserConfig                Interaction.UserConfig();            } while (pEntRes.Status == PromptStatus.Keyword);             if (pEntRes.Status != PromptStatus.OK)            {                // User leaves instead...                return;            }  

ingenieur3d:
Ah, thanks a lot! Less than one month of C# practice got me here.

The if(pEntRes.Status == PromptStatus.Keyword) is still needed of course, and the do goes on top.
(no need to check for the .StringResult as I have only one Keyword.)



--- Code - C#: ---    do    {        // Define the .GetEntity request.        pEntOpts = new PromptEntityOptions(Environment.NewLine + "Select a line or a polyline or : ")        { AllowObjectOnLockedLayer = true, AllowNone = true, AppendKeywordsToMessage = true };        pEntOpts.SetRejectMessage(Environment.NewLine + "Your selection must be a line or a polyline.");        pEntOpts.Keywords.Add("Settings");        ...         // Ask the user to .GetEntity.        pEntRes = acDoc.Editor.GetEntity(pEntOpts);         if (pEntRes.Status == PromptStatus.Keyword)        {            // Change UserConfig            Interaction.UserConfig();        }    } while (pEntRes.Status == PromptStatus.Keyword);  

Navigation

[0] Message Index

Go to full version