X-DATA添加延伸数据库
借用魔法书中案例。(defun c:tt()
(regapp "SAKURA") ;;注册专属应用名称
(setq new_s (getstring "编号<A0001>:"))
(if (= new_s "") (setq new_s "A0001"))
(setq new_i (getint "\n整数值<123>:"))
(if (null new_i) (setq new_i 123))
(setq new_r (getreal "\n实数值<45.8>:"))
(if (null new_r) (setq new_r 45.8))
(setq en (car (entsel "\n选取对象:")))
(ifen
(progn
;-------------- 延伸数据的要求格式
;-------------- (-3 ("SAKURA" (1000 . "A0001")(1070 . 123)(1040 . 45.8)))
(setq new_ext_list(list -3 (list "SAKURA"
(cons 1000 new_s) ;群码1000必须是字符串
(cons 1070 new_i) ;群码1070必须是整数
(cons 1040 new_r)))) ;群码1040必须是实数
(setq endata (entget en))
(setq entype (cdr (assoc 0 endata)))
(if (setq old_ext_list (assoc -3 endata))
(setq endata (subst new_ext_list old_ext_list endata))
(setq endata (append endata (list new_ext_list)))
)
(entmod endata)
(alert (strcat "● " entype " ●" "添加延伸数据库成功→ " new_s "," (itoa new_i) "," (rtos new_r)))
)
)
(prin1)
)
(defun c:tt()
(setq en (car (entsel "选取欲查询延伸数据的对象:")))
(if en
(progn
(setq endata(entget en '("SAKURA")))
(if (setq old_ext_list(assoc -3 endata))
(progn
(setq extlist1(cadr old_ext_list))
(setq old_s (cdr (assoc 1000 (cdr extlist1))))
(setq old_i (cdr (assoc 1070 (cdr extlist1))))
(setq old_r (cdr (assoc 1040 (cdr extlist1))))
(alert (strcat "编号 → " old_s
"\n整数 → " (itoa old_i)
"\n实数 → " (rtos old_r 2 2)
))
)
(alert "无任何延伸数据!!!")
)
)
)
(prin1)
)
这个叫扩展数据,另外一个存储数据的叫做词典 试一下,谢谢分享
Thanks for sharing (I'm collecting function ^^) 试了一下没看懂干嘛用的呢 莫笑我谁解释一下 干嘛用的啊 盲学也是人才啊
页:
[1]