Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to change system variable?
Message
General information
Forum:
CAD
Category:
Autocad Lisp
Miscellaneous
Thread ID:
00411664
Message ID:
00411889
Views:
10
Roi, this is realy nice of you to share all the code with us.
Maby you like to upload some of your function in the download section of this forum.

Again thank you for your help.


>>How can I change system variable from a lisp program?
>>For exemple I like to the the _FILEDIA system variable.
>
>(setvar "SomeSysVar" SomeValue) ; Sets the var
>(getvar "SomeSysVar") ; returns the current value
>
>:)
>
>Below are a couple functions I use to both store and restore any sysvars that a program may change.
>
>At the beginning of a function you would call SysVarStore like this:
>
(SysVarStore
>    '("CMDECHO"     "BLIPMODE"	   "MENUECHO"	 "CECOLOR"
>      "CLAYER"	     "HIGHLIGHT"   "LIMCHECK"	 "CMDDIA"
>      "FILEDIA"     "ATTDIA"	   "REGENMODE"	 "LUNITS"
>      "LUPREC"
>     )
>) ;_ end of SysVarStore
>
>and each of the sysvars in the list has it's value captured. Then at the end of the function you would call SysVarReset to restore thier original values. It works by creating a global var of a list that contains each sysvar and it's current value.
>
>
;;;==================================================================
>;;;  (SysVarStore v)
>;;;		Store system variables
>;;;------------------------------------------------------------------
>;;; Parameters:
>;;;		v	list of var names to store ("CMDECHO" "CLAYER")
>;;;------------------------------------------------------------------
>;;;	Returns:
>;;;		sets global var Lobot:SVARS
>;;;------------------------------------------------------------------
>(defun SysVarStore (v)
>	(setq Lobot:SVARS '())
>	(repeat	(length v)
>		(setq Lobot:SVARS
>				 (cons (list (car v) (getvar (car v)))
>					   Lobot:SVARS
>				 ) ;_ end of cons
>		) ;_ end of setq
>		(setq v (cdr v))
>	) ;_ end of repeat	
>) ;_ end of defun
>;;;==================================================================
>;;;  (SysVarReset)
>;;;		Reset system vars changed by SysVarStore
>;;;------------------------------------------------------------------
>;;; Parameters:
>;;;		uses global var Lobot:SVARS
>;;;------------------------------------------------------------------
>;;;	Returns:
>;;;		always returns nil
>;;;------------------------------------------------------------------
>(defun SysVarReset ()
>	(if	Lobot:SVARS
>		(progn
>			(repeat	(length Lobot:SVARS)
>				(setvar (caar Lobot:SVARS) (cadar Lobot:SVARS))
>				(setq Lobot:SVARS (cdr Lobot:SVARS))
>			) ;_ end of repeat
>			(setq Lobot:SVARS nil)
>		) ;_ end of progn
>	) ;_ end of if
>) ;_ end of defun
>
Previous
Reply
Map
View

Click here to load this message in the networking platform