求数据扩展函数,也就是扩展DXF码的,不知道这样描述是否正确?
已知通过(setq data(entget(car(entsel))))可以得到所选择对象的DXF组码((-1 . <图元名: 7ef7e798>) (0 . "MTEXT") (330 . <图元名: 7ef7ccf8>)
(5 . "2C3") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
"AcDbMText") (10 469.944 -134.491 0.0) (40 . 1.0) (41 . 0.0) (71 . 1) (72 . 5)
(1 . "8-31") (7 . "mystyle") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 2.43691)
(43 . 1.0173) (50 . 0.0) (73 . 1) (44 . 1.0))
现在求一个可扩展、删除此组码内容的函数,再时想知道哪些是CAD官方允许自己扩展的,我知道-1 0 1等是CAD保留的,但1000 1001是不是专门用来扩展的?
我希望的函数格式如下(函数 扩展编号 值)如(函数 1000 “今天天气不错”)此函数最好支持数据更新,即当询到1000对应的数据为空是添加,如果有旧值则用新值更新
删除扩展数据的函数格式如下(函数 扩展编号)如(函数 1001)
字典和扩展数据有何不同?谢谢啦!
;;以下内容的作者是伟大的 王荣和顾国维
;;详见《扩展实体数据在给排水工程CAD中的应用》
;;非常感谢这两位作者!网上流传的文章,字体为全角,我将其转化成半角
;;革天明,2012年9月1日
(defun exadd (name typ ed / ss el nel) ;name:扩展实体数据登记名,typ:扩展实体数据内容,ed:图元
(setq ss(cons -3
(list
(cons name
(cons (cons 1002 "{")
(cons (cons 1000 typ) (list (cons 1002 "}")))
)
)
)
) ;定义扩展实体数据库
el(entget ed) ;提取最近画的一个实体的图形数据库
nel (cons ss el) ;把扩展实体数据信息加入到实体数据库中
)
(regapp name)
(entmod nel)
)
;;;查找扩展数据登记名的程序:
(defun exname (ed / cxl)
(setq cxl (cdr (assoc -3 (entget ed '("*")))))
(if cxl
(car (nth 0 cxl))
)
)
;;;对任意选择实体,提取扩展实体数据的程序:
(defun exsub (ed name / ss typ name cxl cn cal ct cbl)
(setq typ(cons 1 "不是所选择实体") ;如果选择实体与所指定的扩展数据名不一致,则提示错误
name (strcase name)
cxl(cdr (assoc -3 (entget ed '("*"))))
)
(if cxl
(progn (setq cn 0)
(while (setq cal (nth cn cxl))
(if (= name (car cal))
(progn (setq ct 0
cal (cdr cal)
)
(while (setq cbl (nth ct cal))
(if (= (car cbl) 1000)
(setq typ cbl
ct10000
cn10000
)
)
(setq ct (+ ct 1))
)
)
)
(setq cn (+ cn 1))
)
)
)
(cdr typ)
)
见36楼http://bbs.mjtd.com/thread-95716-4-1.html
不明白G版使用的是什么原理 搜索关键词:扩展数据 yjr111 发表于 2012-8-31 20:05 static/image/common/back.gif
搜索关键词:扩展数据
下午已搜索,无直接结果
页:
[1]