Jump to content

Reactor, detect close 'Cancel' button


Aftertouch

Recommended Posts

Hello all,

 

I use a LISP that uses the vlr-commandended reactor, linked to the CLOSE command.

But when the user clicks the CANCEL button in the close command, AutoCAD detects this as vlr-commandended, and not as vlr-commancancelled.

I asume vlr-cancelled only detects the ESCAPE button?

 

How can i 'catch' the cancel button in the CLOSE prompt, so i wont execute the vlr:commandended function.

 

;;--------------------------------------------;;
;;--------------------------------------------;;

(if (not AFTERCLOSE)
	(setq AFTERCLOSE (vlr-command-reactor nil '((:vlr-commandended . CMDAFTERCLOSE)(:vlr-commandcancelled . CMDAFTERCLOSECANCEL))))
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(defun CMDAFTERCLOSE (rea lst / )
	(if (vl-position (car lst)'("CLOSE" "CLOSEALL" "QUIT"))
		(progn
			DO SOMETHING HERE			
		)
	)
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(defun CMDAFTERCLOSECANCEL (rea lst / )
	(if (vl-position (car lst)'("CLOSE" "CLOSEALL" "QUIT"))
		(progn
			DO SOMETHING HERE			
		)
	)
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(princ)

;;--------------------------------------------;;
;;--------------------------------------------;;

 

Link to comment
Share on other sites

An alternative is that you can Redefine a command, so "Close" could draw a line, you can make your own defun that is called when you type "close" and  will run the steps you want. You can do Undefine to reset it at any time, also in a menu/toolbar you can do your defun. You can still force a "._CLOSE" if I remember correct. 

 

Look at help
https://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-38D0244E-C0C7-4FF0-A4B9-DE6E05635BD6

Edited by BIGAL
Link to comment
Share on other sites

Since you're reacting specifically to the use of the CLOSE/QUIT commands, you might instead consider the use of a vlr-dwg-reactor with a callback function triggered on the :vlr-beginClose event or a vlr-docmanager-reactor with a callback function triggered on the :vlr-documentToBeDestroyed event.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...