Making "Repeat Last Command" ignore certain commands

Is there any way to redefine a command with Lisp so that it does not become the "last command" which is repeated when the user presses Enter or Space?

I would like to redefine "Erase," "Undo," and "Save" so that they are not repeated; and, if possible, so that the last command that was not one of those three is repeated.

Comments

  • Dear Anthony,

    in theory, this is possible using
    (vlax-add-cmd global-name func-sym [local-name cmd-flags])

    global-name is the command name (as user enters on commandline)
    func-sym is your command Lisp routine, but without C: prefix
    local-name is optional a translated/localised name
    cmd-flags are the ARX-style command flags combined :
       ACRX_CMD_MODAL or ACRX_CMD_TRANSPARENT
       combined with
      
    ACRX_CMD_NOHISTORY
       and probably some more flags, like for command definition in ARX/BRX

    I did not try this in full extents, but at least it works for most cases ... so give it a try :-)

    Note :
    such a command is like an ARX-registereed command, automatically available in all drawings, so be careful when re-loading Lisp code per drawing.

    Good Luck & many greetings
    Torsten
  • ooops, corrupted by the forum renderer ... trying again :

    in theory, this is possible using
    (vlax-add-cmd global-name func-sym [local-name cmd-flags])

    global-name is the command name (as user enters on commandline)
    func-sym is your command Lisp routine, but without C: prefix
    local-name is optional a translated/localised name
    cmd-flags are the ARX-style command flags combined

    [code]
       ACRX_CMD_MODAL or ACRX_CMD_TRANSPARENT
       combined with
       ACRX_CMD_NOHISTORY
    [/code]

    and probably some more flags, like for command definition in ARX/BRX

    I did not try this in full extents, but at least it works for most cases ... so give it a try :-)

    Note :
    such a command is like an ARX-registereed command, automatically available in all drawings, so be careful when re-loading Lisp code per drawing.

  • @ Torsten:
    Thank you for that information.
    Two remarks:
    1.
    The Lisp-engine does not recognise the value of ACRX_CMD_NOHISTORY (8388608)  and other ACRX_CMD_* values.
    2.
    If a new drawing is opened the global-name is recognised but still the lisp-function has to be reloaded and the call to (vlax-add-cmd) has to be repeated.
  • Dear Roy, Dear Anthony,

    right :-) I just checked, the commands are registered in the "per-document" group, therefore,
    Lisp function code must be loaded (either), and (vlax-add-command) must also be repeated ...
    so thinking about, I guess, it is even the better approach (I remember, Acad also registered
    such commands in the "per-document" command group.

    So for Lisp, this is safer and more consistent, to load + define in each drawing :-)

    For ACRX_CMD_NOHISTORY and the other values : indeed, those are not pre-defined as Lisp symbols ...
    but a good idea to do so (I will add those names) :-)
    Currently, the numeric value as documented in ARX + BRX for addCommand() functions must be used.

    Many thanks again & many greetings
    Torsten
  • So is that a yes or a no?
    I appreciate the replies, but the discussion is so far over my head that I can't even tell whether it concludes that there is or isn't "any way to redefine a command with Lisp so that it does not become the last command which is repeated when the user presses Enter or Space."
    If there is, I'll start researching the terms used, in the hope of some day understanding what was said here.
    Thanks very much, Torsten and Roy. I'm glad to see you're both still active in this forum, and I hope to resume learning from you as in the past.
  • @ Anthony:
    Testing this some more I find that I can't get this to work without problems.

    My test code (note: the ERASE command is not redefined):
    [code](defun MyErase ()
      (princ "\nMyErase ")
      (command "_.erase")
      (while (/= (getvar 'cmdactive) 0)
        (command pause)
      )
      (princ)
    )
    (vlax-add-cmd "MyErase" 'MyErase "MyErase" 8388608)[/code]

    If I load the lisp the 'MyErase' command is defined and it will not be repeated if the user hits Enter or Space.
    But after calling the 'MyErase' command once or twice there are some problems:
    - You can no longer scroll through previous command using the arrow keys.
    - The file dialog is no longer displayed (even though FILEDIA is ON).
    - There is a crash when you save and exit BricsCAD.

    If I try to redefine the ERASE command with the code below, the same problems occur. But there is another problem:
    - BricsCAD will hang when the redefined ERASE command is used the second time.
    [code](defun MyErase ()
      (princ "\nMyErase ")
      (command "_.erase")
      (while (/= (getvar 'cmdactive) 0)
        (command pause)
      )
      (princ)
    )
    (command "_.undefine" "erase")
    (vlax-add-cmd "erase" 'MyErase "erase" 8388608)[/code]
  • @ Torsten:
    If you add a command using (vlax-add-cmd) and then open a new drawing, the Auto-Complete feature will recognise the command name in the new drawing, but the command will not work. This is not logical.
  • Dear Roy,

    thanks for testing !
    Indeed, it is possible that AutoComplete shows the name ... there is a simple logic behind :
    those commands defined via (vlax-add-command) are defined like ARX/BRX commands, while Lisp commands are defined slightly different
    (the native, the ARX/BRX, the VBA, and the Lisp commands use different classes, all based on same base-class; these class instances are all
    added to the so-colled "command stack")

    Now, the AutoComplete knows about these different classes and looks-up differently for them ...
    but it does not know about that specialty, to have Lisp based commands in ARX/BRX command list :-)

    So AutoComplete seems not to verify the "per-document" command against the actual document ... would likely bit heavy work,
    and slow-down AutoComplete; I will contact our developer who implemented AutoComplete.

    Regarding the crashes :
    many thanks as well !
    I will reproduce the problem, and try to fix ... seems to be an issue indeed.

    Many greetings to all !
This discussion has been closed.