Hello
It is possible to cancel a command using visual lisp reactors, if someone has a possible example. If this is not there another way I could do that. I tried to use UNDEFINE but it works only with own CAD commands and not with Visual Lisp command.
thank you
Example using a Command Reactor to cancel the LINE command:
(if (null *command-reactor*) (setq *command-reactor* (vlr-command-reactor nil '((:vlr-commandwillstart . commandreactorcallback))) ) ) (defun commandreactorcallback ( reactor params / wsh ) (if (eq (strcase (car params)) "LINE") (if (setq wsh (vlax-create-object "WScript.Shell")) (progn (vl-catch-all-apply 'vlax-invoke (list wsh 'sendkeys "{ESC}")) (vlax-release-object wsh) ) ) ) (princ) ) (vl-load-com)
Or, using a more efficient callback function to keep the Windows Script Host Object global:
(if (null *command-reactor*) (setq *command-reactor* (vlr-command-reactor nil '((:vlr-commandwillstart . commandreactorcallback))) ) ) (if (null *editor-reactor*) (setq *editor-reactor* (vlr-editor-reactor nil '((:vlr-beginclose . editorreactorcallback))) ) ) (defun commandreactorcallback ( reactor params ) (if (eq (strcase (car params)) "LINE") (if (setq *wsh* (cond (*wsh*) ((vlax-create-object "WScript.Shell")))) (vl-catch-all-apply 'vlax-invoke (list *wsh* 'sendkeys "{ESC}")) ) ) (princ) ) (defun editorreactorcallback ( reactor params ) (if (and *wsh* (eq 'VLA-OBJECT (type *wsh*)) (not (vlax-object-released-p *wsh*))) (vl-catch-all-apply 'vlax-release-object (list *wsh*)) ) (if (and *command-reactor* (eq 'VLA-OBJECT (type *command-reactor*))) (vlr-remove *command-reactor*) ) (vlr-remove reactor) (princ) ) (vl-load-com)
These are only examples however.
Thank you Lee Mac. But what can be done if needs to abort QSAVE with commandreactor callback-function?
(vla-sendcommand *doc* (chr 3))
where:
(vl-load-com)
(setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
John F. Uhden