- 积分
- 1920
- 明经币
- 个
- 注册时间
- 2014-1-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 liuhaixin88 于 2014-5-17 08:47 编辑
To set and restore system variables, you can also the ai_sysvar function.
This function is available in AutoCAD since a while.
It's defined in acaddoc20XX.lsp (ai_utils.lsp or acad.mnl in older versions), so it's automatically loaded in each document.
Quote
;;; --- ai_sysvar ------------------------------------------
;;; Change system variable settings and save current settings
;;; (Note: used by *merr* to restore system settings on error.)
;;;
;;; The <vars> argument is used to...
;;; restore previous settings (ai_sysvar NIL)
;;; set a single sys'var (ai_sysvar '("cmdecho" . 0))
;;; set multiple sys'vars (ai_sysvar '(("cmdecho" . 0)("gridmode" . 0)))
;;;
;;; defun-q is needed by Visual Lisp for functions which redefine themselves.
;;; it is aliased to defun for seamless use with AutoLISP.
Anywhere in the code, you can call ai_sysvar to save the current value of one or more sysvar and set it a new value (or not).
Example:
 - ;; save and set "osmode" to 0
- (ai_sysvar '("osmode" . 0))
- ...
- ;; save and set "orthomode" to 1 and only save "autosnap"
- (ai_sysvar '(("orthomode" . 1) ("autosnap" . nil)))
- ...
- ;; restor all sysvars
- (ai_sysvar nil)
<EDIT> I forgot to say, the implementation of ai_sysvar is quite interesting with the use of defun-q which allows to store the list of var names ans values within the function.
|
|