System Variables changing on their own?

Have you ever set a system variable and then you are working along and that sysvar is changed to a different value? Many people will ask how or why it "changed itself", which obviously it can't do. Of course what is really going on is a program, whether it be an internally defined command, or a lisp/VBA/ARX routine, has changed it.

So you what if you never typed in SETVAR and changed a variable? What if you made a change to something in the OPTIONS dialog and then it changed "on it's own"?  Many of the settings in the OPTIONS dialog are actually system variables. Look on the Open and Save tab of the Options dialog. If you turn Automatic Save off or change the "Minutes between saves" time, you are actually changing the system variable SAVETIME. On the Drafting tab, changing the AutoSnap Settings changes the AUTOSNAP system variable. There are many more.

So let's rephrase the theme here. You make a change to some setting in AutoCAD, and it doesn't stick. So why is it changing? Let's go back to the Autosave time. You turn it on and set it to 5 minutes, but you check it later and it is turned off. Wouldn't it be nice to be alerted when this setting is changed? Then you would have a pretty good clue as to what is changing it.

Here is some lisp code that will "monitor" a given system variable for changes. In the example below, the sysvar we are going to monitor is SAVETIME. Replace that with the name of the sysvar that you want to monitor, load the code and run the command ALERTME, then get back to work. If and when the sysvar is changed, you will be alerted.

If you want to see this in action, load the code exactly as printed below, run the ALERTME command, and then run the ._PUBLISH command (which changes SAVETIME).

 

Credit Peter Jamtgaard with this code
;--------------------------------------
(defun C:ALERTME ()
   (vl-load-com)
   (setq VTFRXN (vlr-editor-reactor nil '((:VLR-sysVarChanged . VTF))))
)

(defun VTF (CALL CALLBACK)
   (if (= (strcase (car CALLBACK)) (setq str "SAVETIME"))
 (alert (strcat str " has been changed "))
   )
)
;---------------------------------------

dialog


By request, here is a slightly modified version. Add this code to your "acaddoc.lsp" file (if you don't have this file, create it using Notepad or using the VLIDE). Make sure that "acaddoc.lsp" is in your support file search path. This will load this code startup so that any attempts to change SAVETIME will result in it being set back to 5.

If you want to see an alert dialog each time, remove the semicolon from the line that starts with ;(alert...

;--------------------------------------
(defun C:ALERTME ()
   (vl-load-com)
   (setq VTFRXN (vlr-editor-reactor nil '((:VLR-sysVarChanged . VTF))))
)

(defun VTF (CALL CALLBACK)
   (if (and
	 (= (strcase (car CALLBACK)) (setq str "SAVETIME"))
	 (not (eq (getvar str) 5))
       )
       (progn
	 ;(alert (strcat str " has been changed back to 5"))
	 (setvar "SAVETIME" 5)
       )
   )
)
(c:alertme)
;---------------------------------------

 


All content is copyright © CAD PANACEA 2005-2011 unless otherwise noted.
All content of CAD PANACEA is solely my own personal thoughts and opinions and do not those of any other entity or person.
All comments posted to this blog are the sole responsibility of the person making the comment.

 

Google, as a third party vendor, uses cookies to serve ads on this site. Google's use of their cookies enables it to serve ads to users based on their visit to your sites and other sites on the Internet. You may opt out of the use of these cookies by visiting the Google ad and content network privacy policy.

free hit counters

Powered by Drupal, an open source content management system