Repeat Command By Pressing Enter

Started by c2k, September 02, 2009, 11:48:23 AM

Previous topic - Next topic

c2k

Hi,
Does anyone know how to get the command a button performs to repeat by pressing enter at the command line?

What I have noticed is the button executes the command just fine, but if I press enter in order to repeat the command it doesn't repeat the command the button performed, instead it repeats the last command issued before the DCL button was pushed.

Thanks in advance.
**CHRIS
Windows 7 64-bit
AutoCAD Revit MEP Suite 2010

owenwengerd

What you describe indicates that the button lost the input focus. At the end of your button's OnClicked event handler, try setting the input focus back to the button to see if that works for you. You may also need to set the form's Keep Focus property.
Owen Wengerd (Outside The Box) / ManuSoft

c2k

I tried setting the focus back in the lisp... didn't work.  I had the Visual LISP editor open with it set to animate and after hitting the button it starts the function which in turn issues the first of 3 operations.  This operation is an external command that opens a dialog that is not part of the DCL, it is part of a different program.  Once I am done in that dialog & press OK to close it, the function continues and issues the second & third operations which set a value to a progress bar on the form & sets a caption on the form. Then the first operation continues by having me select objects in the drawing.  FYI, the form is a palette (modeless).

When I add the operation to set the focus back it issues it right after the caption is updated and before the external command has me select objects.  So that doesn't work.

I don't think my problem is with the setup of the form, but with AutoCAD not recognizing the function for the button as a command.  Does that make sense?

If I manually type the function name for the button and after running it once, hit enter, it executes it again.  So it works when manually running the function, but not when it is run from the form.  Why would that be?
**CHRIS
Windows 7 64-bit
AutoCAD Revit MEP Suite 2010

owenwengerd

The event handler is executed as a lisp function, not as a command, so that is why it doesn't repeat on its own. You could define a second command that contains the button's event handler code, then change the button's event handler to a single dcl_SendString call that executes the new command. This would allow AutoCAD to process the command in the normal way, thus allowing it to be repeated.
Owen Wengerd (Outside The Box) / ManuSoft

c2k

I figured it had to be something like that.  So even though in the lisp it is defined with a "c:" as in "(defun c:<CONTROL-NAME>_OnClicked (/))" it is only sending it as "(defun <CONTROL-NAME>_OnClicked (/))".

So if my external command is "renumber", instead of issuing "(vl-cmdf "renumber")", I could issue "(dcl_SendString "renumber")"

Thanks for your help.  :)
**CHRIS
Windows 7 64-bit
AutoCAD Revit MEP Suite 2010

owenwengerd

Actually the event handler is called as e.g. (c:<CONTROL-NAME>_OnClicked), but you have the right idea. Also, don't forget to append a space or line feed to the end of your command in the call to dcl_SendString.
Owen Wengerd (Outside The Box) / ManuSoft

c2k

Quote from: owenwengerd on September 03, 2009, 07:39:05 AM
Actually the event handler is called as e.g. (c:<CONTROL-NAME>_OnClicked), but you have the right idea.
OK, I just copied that out of the help file.

Quote from: owenwengerd on September 03, 2009, 07:39:05 AMAlso, don't forget to append a space or line feed to the end of your command in the call to dcl_SendString.
OK, thanks for the additional info.  I will give it a try.
**CHRIS
Windows 7 64-bit
AutoCAD Revit MEP Suite 2010

c2k

 ;D  Alright, that worked great! Thanks again.  8)
**CHRIS
Windows 7 64-bit
AutoCAD Revit MEP Suite 2010