再看看CAD定义的
- ;;cad内部定义函数 From acad.mnl
- ;;; --- 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.
- (defun-q ai_sysvar
- (vars / savevar pair varname varvalue varlist)
- (setq varlist nil)
- ;; place holder for varlist
- (defun savevar (varname varvalue / pair)
- (cond
- ;; if new value is NIL, save current setting
- ((not varvalue)
- (setq varlist
- (cons
- (cons varname (getvar varname))
- varlist
- )
- )
- )
- ;; change sys'var only if it's different
- ((/= (getvar varname) varvalue)
- ;; add current setting to varlist, change setting
- (setq varlist
- (cons
- (cons varname (getvar varname))
- varlist
- )
- )
- (setvar varname varvalue)
- )
- (T nil)
- )
- )
- (cond ;_reset all values
- ((not vars)
- (foreach pair varlist
- (setq varname (car pair)
- varvalue (cdr pair)
- )
- (setvar varname varvalue)
- )
- (setq varlist nil)
- )
- ((not (eq 'LIST (type vars)))
- (princ "\nAI_SYSVAR: 参数类型错。\n")
- )
- ;; set a single system variable
- ((eq 'STR (type (car vars)))
- (savevar (car vars) (cdr vars))
- )
- ;; set multiple system variables
- ((and
- (eq 'LIST (type (car vars)))
- (eq 'STR (type (caar vars)))
- )
- (foreach pair vars
- (setq varname (car pair)
- varvalue (cdr pair)
- )
- (if (not (eq 'STR (type varname)))
- (princ "\nAI_SYSVAR: 参数类型错。\n")
- (savevar varname varvalue)
- )
- )
- )
- (T (princ "\nAI_SYSVAR: 第一个参数有错。\n"))
- ) ;cond
- ;; redefine ai_sysvar function to contain the value of varlist
- (setq ai_sysvar
- (cons (car ai_sysvar)
- (cons (list 'setq 'varlist (list 'quote varlist))
- (cddr ai_sysvar)
- )
- )
- )
- varlist
- ;; return the list
- ) ;_sysvar
|