Resetting Variables Is Throwing Errors?????

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
First off I want to say if at any point I am doing something wrong please correct me. I am learning everything I can but it is quite the process. I've come a long way so far and hope to keep learning more.
So....
I am trying to put some lines of code into an acaddoc.lsp to:
1. Get the system variables at the startup and store them
2. Define another function to reset the variables to the original values, that I can put in all my other code.
The reason for this is that when some of the commands I have are ran it changes things like the osmode and highlight etc etc, but the problem is that it never gets changed back.
My thought is that if I define them at the startup I can then throw them in all the other code..
Here is some of what I am working with
Here below I am attempting to retrieve the current System variables.... this is in my acaddoc.lsp file
(defun SB:old_stm_variables (/ highlight cmddia filedia mirrtext pickadd pickauto pickfirst sdi selectionpreview) (setq highlight (getvar "highlight") cmddia (getvar "cmddia") filedia (getvar "filedia") mirrtext (getvar "mirrtext") pickadd (getvar "pickadd") pickauto (getvar "pickauto") pickfirst (getvar "pickfirst") sdi (getvar "sdi") selectionpreview (getvar "selectionpreview") osmode (getvar "osmode") ) (princ "\nRetrieved Current System Variables") (princ) ) (SB:old_stm_variables)
Next I define the function to reset them to their original state. also in the acaddoc.lsp file
I will then put this at the end of my other custom commands.
(defun SB:reset_variables (/ highlight cmddia filedia mirrtext pickadd pickauto pickfirst sdi selectionpreview) (setvar "highlight" highlight) ; when ran this throws an error below >>> (setvar "cmddia" cmddia) ;>>>error: AutoCAD variable setting rejected: "highlight" nil (setvar "filedia" filedia) (setvar "mirrtext" mirrtext) (setvar "pickadd" pickadd) (setvar "pickauto" pickauto) (setvar "pickfirst" pickfirst) (setvar "sdi" sdi) (setvar "selectionpreview" selectionpreview) (setvar "osmode" osmode) (princ "\nSystems Variables Have Been Reset") (princ) )
Any thoughts or suggestions?
Also why is it not accepting the highlight variable???
Thanks for all the help!