[LISP]設定及還原,u退回
(defun c:test()(s_acad_sysvar)
...
(r_acad_sysvar)
)
(defun s_acad_sysvar()<BR> (setq acad_sysvar_list '("clayer" "osmode" "textstyle" "celtype"))<BR> (setq old_sysvar_list (mapcar 'getvar acad_sysvar_list))<BR> (command "undo" "be")<BR>)<BR>(defun r_acad_sysvar()<BR> (command "undo" "e")<BR> (mapcar 'setvar acad_sysvar_list old_sysvar_list)<BR> (prin1)<BR>) 很好,不过我更喜欢局部变量,稍微改了一下,作成通用函数。(defun c:test ( / NEW_SYSVAR-VAL_LIST OLD_SYSVAR-VAL_LIST) (setqnew_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")
(setqold_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)
)
很好的源代码,谢谢楼主分享。
页:
[1]