lisp 扩展数据
发布网友
发布时间:2022-05-15 20:17
我来回答
共1个回答
热心网友
时间:2024-02-27 15:19
写入扩展数据,下面有些自己写的函数,希望对你有用。
(defun regapp-new (appname)
(if (tblsearch "appid" appname); Checks if already registered.
T
(if(= (regapp appname) nil); Some other problem.
nil
T
)
)
)
(defun get-xdata
(ent appname / ent-data ex-data)
;;; (get-xdata (car (entsel)) "appname")
(setq ent-data (entget ent '("*")))
(if (and (setq ex-data (assoc -3 ent-data))
(setq ex-data (assoc appname (cdr ex-data)))
)
(cdr (assoc 1000 (cdr ex-data)))
)
)
(defun overwrite-xdata (ent appnamevalue /
ent-data ex-dataex-data-old ex-data-new
)
;;; (overwrite-xdata (car (entsel)) "appname" "需要记录的内容")
(setq ent-data (entget ent '("*")))
(setq ex-data (assoc -3 ent-data))
(setq ex-data-old (assoc appname (cdr ex-data)))
(if ex-data-old
(progn (setq ex-data-new
(subst (cons 1000 value)
(assoc 1000 (cdr ex-data-old))
ex-data-old
)
)
(setq ex-data (substex-data-new
ex-data-old
ex-data
)
)
)
(if(regapp-new appname)
(progn (setq ex-data-new
(cons appname
(list (cons 1000 value))
)
)
(setq ex-data (append (if ex-data
ex-data
'(-3)
)
(list ex-data-new)
)
)
)
)
)
(entmod (append (entget ent) (list ex-data)))
)