很好,不过我更喜欢局部变量,稍微改了一下,作成通用函数。- (defun c:test ( / NEW_SYSVAR-VAL_LIST OLD_SYSVAR-VAL_LIST) (setq new_sysvar-val_list
- (list '("clayer" "osmode" "CECOLOR" "textstyle" "celtype")
- '("0" 32 "2" "standard" "ByLayer")
- );;;;提供需设置的系统系统变量及新的参数,一一对应参数列表,注意参数类型的对应关系
- )
- (setq old_sysvar-val_list (set_acad_sysvar new_sysvar-val_list));获得旧的系统变量及参数列表;;; (command "pline" "0,0" "20,20" "40,40" "")
- ;;; (command "pline" "10,0" "20,0" "80,40" "");.......
-
- (r_acad_sysvar old_sysvar-val_list);恢复系统设置)(defun set_acad_sysvar (sysvar-val_list / OLD_SYSVAR-VAL_LIST OLD_SYSVARVAL_LIST);设置新的系统参数,返回系统变量及旧的参数列表
- (setq old_sysvarval_list (mapcar 'getvar (car sysvar-val_list)))
- (mapcar 'setvar
- (car sysvar-val_list)
- (cadr sysvar-val_list)
- )
- (command "undo" "be")
- (setq old_sysvar-val_list
- (list (car sysvar-val_list) old_sysvarval_list)
- )
- )
- (defun r_acad_sysvar (old_sysvar-val_list / );恢复系统设置
- (command "undo" "e")
- (mapcar 'setvar
- (car old_sysvar-val_list)
- (cadr old_sysvar-val_list)
- )
- (prin1)
- )
|