Jump to content

Turn off termporarily snap during matchrpop progress


Recommended Posts

Posted

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

Posted

(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

Posted

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

 

Posted (edited)

 

SNAPMODE effects MATCHPROP? BCAD just normal.

perhaps a reactor, start command MATCHPROP, toggle GRIDMODE to represent SNAPMODE

 

tri7n7U.gif

 

 

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 by hanhphuc
test-end (and... )

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...