Author Topic: Nothing Selected with PromptEntityOptions  (Read 874 times)

0 Members and 1 Guest are viewing this topic.

velasquez

  • Newt
  • Posts: 186
Nothing Selected with PromptEntityOptions
« 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

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 1509
  • class keyThumper<T>:ILazy<T>
Re: Nothing Selected with PromptEntityOptions
« Reply #1 on: July 15, 2022, 12:10:19 AM »

Please post the code you are using ( in English )
called Kerry in my other life

Sometimes the question is more important than the answer.

I don't really work crazy hours . . I just live at UTC + 13.00
#ridesober

velasquez

  • Newt
  • Posts: 186
Re: Nothing Selected with PromptEntityOptions
« Reply #2 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();
       
        }






It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7496
  • AKA Daniel
Re: Nothing Selected with PromptEntityOptions
« Reply #3 on: July 15, 2022, 10:31:29 PM »
maybe something to explore, there's an internal function ProcessForNoneOrEmptySel int PromptEditorOptions


« Last Edit: July 16, 2022, 12:34:42 AM by It's Alive! »
Retired

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 1509
  • class keyThumper<T>:ILazy<T>
Re: Nothing Selected with PromptEntityOptions
« Reply #4 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)
« Last Edit: July 15, 2022, 11:29:22 PM by kdub »
called Kerry in my other life

Sometimes the question is more important than the answer.

I don't really work crazy hours . . I just live at UTC + 13.00
#ridesober

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7496
  • AKA Daniel
Re: Nothing Selected with PromptEntityOptions
« Reply #5 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

Retired

gile

  • Water Moccasin
  • Posts: 2406
  • Marseille, France
Re: Nothing Selected with PromptEntityOptions
« Reply #6 on: July 16, 2022, 04:41:13 AM »
Perhaps playing with the NOMUTT sysvar?
Speaking English as a French Frog

velasquez

  • Newt
  • Posts: 186
Re: Nothing Selected with PromptEntityOptions
« Reply #7 on: July 16, 2022, 09:17:46 AM »
Perhaps playing with the NOMUTT 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

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 1509
  • class keyThumper<T>:ILazy<T>
Re: Nothing Selected with PromptEntityOptions
« Reply #8 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,
called Kerry in my other life

Sometimes the question is more important than the answer.

I don't really work crazy hours . . I just live at UTC + 13.00
#ridesober

velasquez

  • Newt
  • Posts: 186
Re: Nothing Selected with PromptEntityOptions
« Reply #9 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.

gile

  • Water Moccasin
  • Posts: 2406
  • Marseille, France
Re: Nothing Selected with PromptEntityOptions
« Reply #10 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 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.             }
Speaking English as a French Frog

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 1509
  • class keyThumper<T>:ILazy<T>
Re: Nothing Selected with PromptEntityOptions
« Reply #11 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.
called Kerry in my other life

Sometimes the question is more important than the answer.

I don't really work crazy hours . . I just live at UTC + 13.00
#ridesober

velasquez

  • Newt
  • Posts: 186
Re: Nothing Selected with PromptEntityOptions
« Reply #12 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.