SNAPMODE and OSMODE Toggle command

SNAPMODE and OSMODE Toggle command

CHRISTINA_GAITANTZI_35734
Explorer Explorer
260 Views
2 Replies
Message 1 of 3

SNAPMODE and OSMODE Toggle command

CHRISTINA_GAITANTZI_35734
Explorer
Explorer

Hello, everyone! I've been trying to create a simple lisp command that, depending on the value of the system variable SNAPMODE (either 0 or 1), toggles between two states of set values for both SNAPMODE and OSMODE. I want to be able to achieve the following:

  • If SNAPMODE equals 0, set SNAPMODE to 1 and OSMODE to 0.
  • If SNAPMODE equals 1, set SNAPMODE to 0 and OSMODE to 72.

I would have thought that with my barely basic knowledge of LISP I could easily figure it out using a few lines, but I guess not. I'm pasting the code I wrote, so maybe you guys can help me out.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Switch from OSMODE Snap to SNAPMODE Grid

(defun C:SGS ()
	(if (= "SNAPMODE" 0)
		(progn (setvar "SNAPMODE" 1) (setvar "OSMODE" 0));progn true
		(progn (setvar "SNAPMODE" 0) (setvar "OSMODE" 72));progn false
	);if
	(princ)
);defun SGS
(princ)

 

Thanks in advance!

0 Likes
Accepted solutions (1)
261 Views
2 Replies
Replies (2)
Message 2 of 3

johnyDFFXO
Advocate
Advocate
Accepted solution

Just a hint - you're missing GETVAR.

Message 3 of 3

CHRISTINA_GAITANTZI_35734
Explorer
Explorer

Thanks a lot! I was missing just that!

In any case, for anyone who may be interested, I'm pasting the new code below:

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Switch from OSMODE Snap to SNAPMODE Grid

(defun C:SGS ()
	(if (= (getvar 'SNAPMODE) 0)
		(progn (setvar 'SNAPMODE 1) (setvar 'OSMODE 0));progn true
		(progn (setvar 'SNAPMODE 0) (setvar 'OSMODE 72));progn false
	);if
	(princ)
);defun SGS
(princ)
0 Likes