明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2614|回复: 3

[LISP]設定及還原,u退回

[复制链接]
发表于 2004-7-3 11:53 | 显示全部楼层 |阅读模式
(defun c:test() (s_acad_sysvar) ... (r_acad_sysvar) ) (defun s_acad_sysvar()
(setq acad_sysvar_list '("clayer" "osmode" "textstyle" "celtype"))
(setq old_sysvar_list (mapcar 'getvar acad_sysvar_list))
(command "undo" "be")
)
(defun r_acad_sysvar()
(command "undo" "e")
(mapcar 'setvar acad_sysvar_list old_sysvar_list)
(prin1)
)
发表于 2004-7-4 14:08 | 显示全部楼层
很好,不过我更喜欢局部变量,稍微改了一下,作成通用函数。
  1. (defun c:test ( / NEW_SYSVAR-VAL_LIST OLD_SYSVAR-VAL_LIST)   (setq  new_sysvar-val_list
  2.    (list '("clayer" "osmode" "CECOLOR" "textstyle" "celtype")
  3.                '("0" 32 "2" "standard" "ByLayer")
  4.    );;;;提供需设置的系统系统变量及新的参数,一一对应参数列表,注意参数类型的对应关系
  5.    )
  6.    (setq old_sysvar-val_list (set_acad_sysvar new_sysvar-val_list));获得旧的系统变量及参数列表;;;   (command "pline" "0,0" "20,20" "40,40" "")
  7. ;;;   (command "pline" "10,0" "20,0" "80,40" "");.......
  8.    
  9.    (r_acad_sysvar old_sysvar-val_list);恢复系统设置)(defun set_acad_sysvar (sysvar-val_list / OLD_SYSVAR-VAL_LIST OLD_SYSVARVAL_LIST);设置新的系统参数,返回系统变量及旧的参数列表
  10.    (setq old_sysvarval_list (mapcar 'getvar (car sysvar-val_list)))
  11.    (mapcar 'setvar
  12.      (car sysvar-val_list)
  13.      (cadr sysvar-val_list)
  14.    )
  15.    (command "undo" "be")
  16.    (setq  old_sysvar-val_list
  17.    (list (car sysvar-val_list) old_sysvarval_list)
  18.    )
  19. )
  20. (defun r_acad_sysvar (old_sysvar-val_list / );恢复系统设置
  21.    (command "undo" "e")
  22.    (mapcar 'setvar
  23.      (car old_sysvar-val_list)
  24.      (cadr old_sysvar-val_list)
  25.    )
  26.    (prin1)
  27. )
发表于 2016-10-21 09:02 | 显示全部楼层
很好的源代码,谢谢楼主分享。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-20 02:28 , Processed in 0.497529 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表