Author Topic: cancel SSGET  (Read 4015 times)

0 Members and 1 Guest are viewing this topic.

masoud_123

  • Guest
cancel SSGET
« on: June 17, 2012, 11:59:35 PM »
Hi

Could you please help me, how can I cancel "Select Object" (SSGET)  prompt  using lisp like entering "ESCAPE" key form keyboard?
Is there any function that acts like "ESCAPE" key?


owenwengerd

  • Bull Frog
  • Posts: 452
Re: cancel SSGET
« Reply #1 on: June 18, 2012, 12:54:04 AM »
Use the (command) function with no arguments.

masoud_123

  • Guest
Re: cancel SSGET
« Reply #2 on: June 18, 2012, 03:36:03 AM »
(command) function seems doesn't work.
when using (command) to cancel (SSGET), Autocad prompts *Invalid Selection*.

Tharwat

  • Swamp Rat
  • Posts: 712
  • Hypersensitive
Re: cancel SSGET
« Reply #3 on: June 18, 2012, 03:42:30 AM »
Right click with your mouse , would cancel the selection set and return nil .

masoud_123

  • Guest
Re: cancel SSGET
« Reply #4 on: June 18, 2012, 04:06:06 AM »
how to Right Click in Lisp? Is it possible?

Tharwat

  • Swamp Rat
  • Posts: 712
  • Hypersensitive
Re: cancel SSGET
« Reply #5 on: June 18, 2012, 04:12:24 AM »
Post your codes to let all members understand your views and to give you the correct answer if that possible .

masoud_123

  • Guest
Re: cancel SSGET
« Reply #6 on: June 18, 2012, 04:24:09 AM »
We have a form and 2 buttons on it.

We want to apply (SSGET) by pressing one of buttons and CANCEL it (like pressing ESCAPE key from keyboard) by another one.

Applying SSGET is ok but how can I cancel SSGET by pressing a button? Is it possible to enter Escape key in Vlisp?

hope to be clear!

Tharwat

  • Swamp Rat
  • Posts: 712
  • Hypersensitive
Re: cancel SSGET
« Reply #7 on: June 18, 2012, 04:34:54 AM »
STILL GUESSING .

Maybe function redraw with the mode of 4 could reach your needs (redraw <ename> 4)  :laugh:

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: cancel SSGET
« Reply #8 on: June 18, 2012, 04:43:17 AM »
AutoLisp/VisualLisp is incapable of doing two things at once - that's due to ADesk implementing the lisp interpreter into one single thread. Thus you cannot send anything to the command-line while some other lisp code is running and waiting for user input.

You can attempt to circumvent this by using some form of SendKey's through ActiveX - but the problem is it might work in some cases while in others it might not. The SendKeys is asynchronous (otherwise it would be the exact same thing as if using command / vl-cmd) and thus would not give any benefit to AutoLisp. But, since it's asynchronous you can't say for sure when the keystrokes are actually sent to the command.

But the biggest problem is sending an Esc this way would cancel all running lisp, including your own routine.

Could you post some code instead of describing your problem? It might be that you can rewrite some to go about it a different way. I can't actually understand why you'd want to cancel a call to ssget.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

masoud_123

  • Guest
Re: cancel SSGET
« Reply #9 on: June 18, 2012, 05:11:29 AM »
Thank you irneb.

My code is very huge and I can not post it.

I want to cancel a call to ssget because the user of software wants it!

Assume there are 5 objects that user want to select 4, 5 or some of them using ssget. Is there any way after selecting of  desired objects are completed, user press a button, and selection finishes? like pressing enter during SSGET?

Is there any way to Cancel/Finish selecting object using SSGET in vlisp?

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: cancel SSGET
« Reply #10 on: June 18, 2012, 05:44:05 AM »
Is there any way to Cancel/Finish selecting object using SSGET in vlisp?
The problem is this:
Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssget)) ;This is waiting for user input so the next line will not even compute before the user presses Enter/Space
  2. (command "")
You coul "try" the SendKeys as I've stated:
Code - Auto/Visual Lisp: [Select]
  1. (defun SendKeys (keys / ws)
  2.   (setq ws (vlax-get-or-create-object "WScript.Shell"))
  3.   (vlax-invoke-method ws 'SendKeys keys)
  4.  
  5. (SendKeys "{ENTER}") ;Sends the Enter key to the active window
  6. (SendKeys "{ESCAPE}") ;Sends the Esc key to the active window
The "problem" is where do you call this? Before you start the ssget? If so the ssget would never wait for any user input since you've already sent the Enter / Esc before even starting a selection.

After calling ssget? Nope, because any lines after ssget would only run once ssget finishes.

From something else? You mean a toolbar button? Or a button from an ODCL modeless-dialog? You could try it, but I doubt it would work. If a toolbar button, try just making the macro of the button ";" for enter or "^C" for Esc. Just remember "Esc" always stops all lisp - no matter what - only the *error* routine is called after an Esc, everything else is simply stopped and canceled.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: cancel SSGET
« Reply #11 on: June 18, 2012, 08:11:58 AM »
I think you will need to simulate the ssget function.
But what exactly are you having the USER do? Select points or pick the objects or what?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

masoud_123

  • Guest
Re: cancel SSGET
« Reply #12 on: June 18, 2012, 08:54:16 AM »
the users must pick the objects.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: cancel SSGET
« Reply #13 on: June 18, 2012, 09:35:04 AM »
OK, so you're requesting the user to pick / select the objects. But you don't want them to press Enter/Space to finish the selection - you rather want to give them a button to stop selecting. IMO the only way to do that is to make a button inside CUI with a macro of ";" so that the button press actually sends an Enter to ssget.

If you mean you want to only allow them to pick 5 (or less) objects, then entsel 5 times (max in a while loop - adding each to a list) instead of using ssget.

This is why we're asking for code to figure out which method (of many others) would be more conducive to your situation. Even if you can just post a portion of your code it might help a lot.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.