I'm looking for a lisp routine to turn the node osnap on and off with a hot key

I'm looking for a lisp routine to turn the node osnap on and off with a hot key

Anonymous
Not applicable
771 Views
3 Replies
Message 1 of 4

I'm looking for a lisp routine to turn the node osnap on and off with a hot key

Anonymous
Not applicable

I want to be able to turn on the node osnap with a quick button and then be able to turn if back off and my osnaps go back to what I had them at by clicking another button.  It would need to be for 2d and 3d.

 

I would appreciate any help.  Thanks

0 Likes
772 Views
3 Replies
Replies (3)
Message 2 of 4

rkmcswain
Mentor
Mentor

Try this. You didn't mention this, but it does not accommodate if the 16384 flag is set (which turns off running object snaps). 

 

(defun C:foo ()
  (if (zerop (logand 8 (getvar "osmode")))
    (setvar "OSMODE" (logior (getvar "OSMODE") 8))
    (setvar "OSMODE" (logand (getvar "OSMODE") (~ 8)))    
  )
)
;; source
;; https://forums.autodesk.com/t5/autocad-forum/aperture-box-and-osmode/m-p/2673449#M261990
R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 4

john.uhden
Mentor
Mentor

Maybe I am missing the question, but have you tried the F3 key?

John F. Uhden

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... to turn on the node osnap with a quick button and then be able to turn if back off and my osnaps go back to what I had them at by clicking another button.  ....


 

If you mean to add  NODE Osnap to whatever modes you currently have running, and conversely to remove it, this is all you need, and you need only one  button containing it [it toggles  NODE in or out, whatever is not the current condition]:

 

(setvar 'osmode (boole 6 (getvar 'osmode) 8))

 

If you mean to switch to NODE only, and conversely back to whatever combination you had running before [even if it may have included  NODE], that's a different story.  I assumed the former because of your wording "turn on" rather than something like "switch to," but let us know if you really want the latter.

Kent Cooper, AIA