明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1013|回复: 1

[提问] 请教,以下内容要如何理解?

[复制链接]
发表于 2014-5-17 08:46 | 显示全部楼层 |阅读模式
本帖最后由 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:
    1. ;; save and set "osmode" to 0
    2. (ai_sysvar '("osmode" . 0))
    3. ...
    4. ;; save and set "orthomode" to 1 and only save "autosnap"
    5. (ai_sysvar '(("orthomode" . 1) ("autosnap" . nil)))
    6. ...
    7. ;; restor all sysvars
    8. (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.
发表于 2014-5-17 09:06 | 显示全部楼层
本帖最后由 自贡黄明儒 于 2014-5-17 10:14 编辑

找到ai_sysvar的定义,一切都清楚了
http://www.askcad.com/bbs/thread-47222-1-1.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 08:50 , Processed in 0.206986 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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