TheSwamp

Code Red => .NET => Topic started by: velasquez on July 14, 2022, 07:50:57 AM

Title: Nothing Selected with PromptEntityOptions
Post by: velasquez on July 14, 2022, 07:50:57 AM
Hello
I'm working with PromptEntityOptions and I need to know if there is a way to Suppress or Translate the prompt "Nothing Selected."
when no entity is selected.

Thanks
Title: Re: Nothing Selected with PromptEntityOptions
Post by: kdub_nz on July 15, 2022, 12:10:19 AM

Please post the code you are using ( in English )
Title: Re: Nothing Selected with PromptEntityOptions
Post by: velasquez on July 15, 2022, 08:31:22 AM
I'm using this code for testing, I didn't write it.
To test, load the code and click on an empty area of the drawing.
Note the prompt "Nothing Selected."
I need to translate or not show this to the user.
Thanks

Code: [Select]
[CommandMethod("S2T")]
        static public void UpdateTableFromSpreadsheet()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            PromptEntityOptions opt = new PromptEntityOptions("\nSelect table to update: ");
            opt.SetRejectMessage("\nEntity is not a table.");
            opt.AddAllowedClass(typeof(Table), false);
            PromptEntityResult per = ed.GetEntity(opt);
            if (per.Status != PromptStatus.OK)
            {
                return;
            }
            Transaction tr = db.TransactionManager.StartTransaction();
       
        }





Title: Re: Nothing Selected with PromptEntityOptions
Post by: It's Alive! on July 15, 2022, 10:31:29 PM
maybe something to explore, there's an internal function ProcessForNoneOrEmptySel int PromptEditorOptions


Title: Re: Nothing Selected with PromptEntityOptions
Post by: kdub_nz on July 15, 2022, 11:22:45 PM
Hi Daniel,

Where did you find that one ??    . . . looks interesting !

Did they have a sample for usage with C# ?

I asked Mrs Google, she 'knows nothing' to quote Schultz(John Banner)
Title: Re: Nothing Selected with PromptEntityOptions
Post by: It's Alive! on July 16, 2022, 02:49:06 AM
Hi Daniel,

Where did you find that one ??    . . . looks interesting !

Did they have a sample for usage with C# ?

I asked Mrs Google, she 'knows nothing' to quote Schultz(John Banner)

Doesn't work, I thought it would be possible to catch SystemVariableChanged or SystemVariableChanging and veto it.
the only other option I see is to roll your own by p/invoking acedEntSel

Title: Re: Nothing Selected with PromptEntityOptions
Post by: gile on July 16, 2022, 04:41:13 AM
Perhaps playing with the NOMUTT (https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-9289326E-DEE9-40E7-839C-A4B031A29B2A-htm.html) sysvar?
Title: Re: Nothing Selected with PromptEntityOptions
Post by: velasquez on July 16, 2022, 09:17:46 AM
Perhaps playing with the NOMUTT (https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-9289326E-DEE9-40E7-839C-A4B031A29B2A-htm.html) sysvar?

I set the NOMUTT variable to 1 before running the command but it didn't work.
Is there anything similar to the ERRNO sysvar variable in C#?

ERROR CODES REFERENCE (AutoLISP)
(getvar 'ERRNO)
7  -> Object selection: pick failed
52 -> Entity selection: null response
Title: Re: Nothing Selected with PromptEntityOptions
Post by: kdub_nz on July 16, 2022, 08:26:21 PM
Looks to me like the message originates in
Code: [Select]
protected internal sealed override unsafe PromptResult DoIt() . . . and
Code: [Select]
private protected unsafe int ProcessForNoneOrEmptySel(int retcode)

and then further down the rabbit hole.

too deep, and probably not fruitful enough for me to follow due to access restrictions . . .

Regards,
Title: Re: Nothing Selected with PromptEntityOptions
Post by: velasquez on July 17, 2022, 08:01:39 AM
Thank you all for your help.

My intention for the user to enter a loop is to select a block with a mouse click as in (entsel..).
If the ENTER key is pressed the loop is terminated.
If the click is not on the block a custom message is displayed in my language and the loop continues asking for the selection.
Title: Re: Nothing Selected with PromptEntityOptions
Post by: gile on July 17, 2022, 10:27:58 AM
Hi,

From my side (AutoCAD with French Language Pack) this snippet does what you describe, and prompt "Pas de sélection" (in French) in case the user select nothing.
What about using the Language Pack (https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autocad-2022-language-packs.html) corresponding to your language?

Code - C#: [Select]
  1.             var ed = Application.DocumentManager.MdiActiveDocument.Editor;
  2.             var ids = new ObjectIdCollection();
  3.             var peo = new PromptEntityOptions("\nSélectionnez un bloc: ");
  4.             peo.SetRejectMessage("\nL'objet séléctionné n'est pas un bloc.");
  5.             peo.AddAllowedClass(typeof(BlockReference), true);
  6.             peo.AllowNone = true;
  7.             while (true)
  8.             {
  9.                 var per = ed.GetEntity(peo);
  10.                 if (per.Status == PromptStatus.None)
  11.                     break;
  12.                 if (per.Status != PromptStatus.OK)
  13.                     return;
  14.                 ids.Add(per.ObjectId);
  15.             }
Title: Re: Nothing Selected with PromptEntityOptions
Post by: kdub_nz on July 17, 2022, 05:52:41 PM
Good pickup about the 'language' Gile.

I read 'translate' as "use my own message".

Having the message in Portuguese makes more sense to me than having no message at all.
Title: Re: Nothing Selected with PromptEntityOptions
Post by: velasquez on July 18, 2022, 08:42:01 AM
Thanks again for everyone's help.
I'm still studying the AutoCAD API with C# and it's great to have the help of people like you.