PDA

View Full Version : Toggle Sysvars Easily



r.grandmaison
2006-05-08, 04:48 PM
This might be better in the Customization Lisp forum, but it's such a small, but important little tip that I thought I'd post it here.

If you don't use ACAD.LSP (or variants) you should! We use it to provide quick toggles between sysvars that have either a 1 or a 0 value. Tilemode, Pickstyle, etc...those kind. You KNOW what the current value is, you just want to quickly jump to the opposite value, and then back again when needed.

So, copy/paste this bit of code into your ACAD.LSP file and tweak it as needed for your own favorite toggling sysvar:


(defun C:PK ()
(if (= (getvar "Pickstyle") 1)
(setvar "Pickstyle" 0) ; if pickstyle is 1 set it to 0
(setvar "Pickstyle" 1) ; otherwise it is 0 so set it to 1
)
)[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

rkmcswain
2006-05-08, 05:53 PM
That could be shortened to:



(setvar "pickstyle" (abs (1- (getvar "pickstyle"))))

r.grandmaison
2006-05-08, 06:07 PM
That could be shortened to:



(setvar "pickstyle" (abs (1- (getvar "pickstyle"))))
Oh, you're good! :) I like consice code. I'm not a guru at Lisp, just know enough to make things work better around here.

de-co1
2006-05-09, 08:05 AM
I wish someone would create a bit of code so that I could change our LT to full ACAD!!!

:lol:

rkmcswain
2006-05-09, 11:38 AM
I wish someone would create a bit of code so that I could change our LT to full ACAD!!!


Depending on what features you are looking to add, this [ http://www.drcauto.com/ ] may help.