svorgodne Posted June 22, 2020 Posted June 22, 2020 Hello everyone, I need to deactivate thru Autolisp temporarily snap when using "matchprop" command, because we have big drawings and snap freezes autocad in the process. F3 does not work in this case because it is very easy to forget to do it before using the command and restore it later. I am looking for specifically a routine that does it automatically. Any suggestion? thanks in advance Quote
guran Posted June 22, 2020 Posted June 22, 2020 (defun c:SnapO (/ SnapOnOff) (setq SnapOnOff (getvar "osmode")) (if (< SnapOnOff 16384) (setq SnapOnOff (+ SnapOnOff 16384)) ;osnap off (setq SnapOnOff (- SnapOnOff 16384)) ;osnap on );end if (setvar "osmode" SnapOnOff) (princ) );end Quote
BIGAL Posted June 22, 2020 Posted June 22, 2020 Or just set snap to what you want in your code, often I will do multiple osmode's to suit in a code sequence like mid then end 2 & 1 (setq oldsnap (getvar 'osmode)) ; get current snap setting (setvar 'osmode 0) .......your code (setvar 'osmode oldsnap) ; reset snap mode back to what it was Quote
hanhphuc Posted June 23, 2020 Posted June 23, 2020 (edited) SNAPMODE effects MATCHPROP? BCAD just normal. perhaps a reactor, start command MATCHPROP, toggle GRIDMODE to represent SNAPMODE ACAD not tested (vl-load-reactors) (defun c:test-start ( ) ; hp 23.06.2020 (and matchprop-snap-reactor (vlr-added-p matchprop-snap-reactor) (vlr-remove matchprop-snap-reactor) ) (setq *matchprop-snapmode* (mapcar 'getvar '(snapmode gridmode)) matchprop-snap-reactor (vlr-command-reactor nil '((:vlr-commandwillstart . matchprop-snap-turn-off) (:vlr-commandEnded . matchprop-snap-restore) (:VLR-commandCancelled . matchprop-snap-restore) ) ) ) (grtext -1 "\nMatchprop-snap-reactor activated! ") (princ) ) (defun matchprop-snap-turn-off (react callback ) (grtext -1 "\nMatchprop-snap-reactor. ") (if (wcmatch (vl-princ-to-string (car callback)) "*MATCHPROP*") (princ (strcat "\nSNAPMODE = " (itoa (car (mapcar 'setvar '(snapmode gridmode) '(0 0)))))) ) (princ) ) (defun matchprop-snap-restore (react callback ) (if (and (wcmatch (vl-princ-to-string (car callback)) "*MATCHPROP*") *matchprop-snapmode* ) (princ (strcat "\nSNAPMODE = "(itoa (car (mapcar 'setvar '(snapmode gridmode) *matchprop-snapmode*))))) ) (grtext -1 "\nMatchprop-snap-reactor. ") (princ) ) (defun c:test-end () (grtext) (princ "\nmatchprop-snap-reactor ended!") (and matchprop-snap-reactor (vlr-added-p matchprop-snap-reactor) (vlr-remove matchprop-snap-reactor) ) (princ) ) Edited June 23, 2020 by hanhphuc test-end (and... ) Quote
Recommended Posts
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.